Fix
This commit is contained in:
parent
dd795aa7a0
commit
af72de7b3b
8 changed files with 193 additions and 317 deletions
|
@ -1,16 +1,9 @@
|
||||||
# See here for more informations
|
|
||||||
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
|
||||||
|
|
||||||
# Move this file from check_process.default to check_process when you have filled it.
|
|
||||||
|
|
||||||
;; Test complet
|
;; Test complet
|
||||||
; Manifest
|
; Manifest
|
||||||
domain="domain.tld" (DOMAIN)
|
domain="domain.tld"
|
||||||
path="/" (PATH)
|
path="/"
|
||||||
is_public=1 (PUBLIC|public=1|private=0)
|
is_public=1
|
||||||
# password="pass"
|
port="9980"
|
||||||
# nextclouddomain="domain.tld"
|
|
||||||
port="9980" (PORT)
|
|
||||||
; Checks
|
; Checks
|
||||||
pkg_linter=1
|
pkg_linter=1
|
||||||
setup_sub_dir=0
|
setup_sub_dir=0
|
||||||
|
@ -21,22 +14,7 @@
|
||||||
upgrade=1
|
upgrade=1
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=1
|
multi_instance=1
|
||||||
incorrect_path=1
|
|
||||||
port_already_use=0
|
|
||||||
change_url=0
|
change_url=0
|
||||||
;;; Levels
|
|
||||||
Level 1=auto
|
|
||||||
Level 2=auto
|
|
||||||
Level 3=auto
|
|
||||||
# Level 4:
|
|
||||||
Level 4=1 (This app supports the Nextcloud LDAP auth)
|
|
||||||
# Level 5:
|
|
||||||
Level 5=auto
|
|
||||||
Level 6=auto
|
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||||
location __PATH__/ {
|
location __PATH__/ {
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"en": "Scratch package for YunoHost.",
|
"en": "Scratch package for YunoHost.",
|
||||||
"fr": "Scratch pour YunoHost."
|
"fr": "Scratch pour YunoHost."
|
||||||
},
|
},
|
||||||
"version": "3.0-Beta",
|
"version": "3.0-Beta~ynh1",
|
||||||
"url": "https://scratch.mit.edu/",
|
"url": "https://scratch.mit.edu/",
|
||||||
"license": "non-free",
|
"license": "non-free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
@ -14,32 +14,23 @@
|
||||||
"email": "liberodark@gmail.com"
|
"email": "liberodark@gmail.com"
|
||||||
},
|
},
|
||||||
"requirements": {
|
"requirements": {
|
||||||
"yunohost": ">= 2.7.2"
|
"yunohost": ">= 4.2.4"
|
||||||
},
|
},
|
||||||
"multi_instance": true,
|
"multi_instance": true,
|
||||||
"services": [
|
"services": [
|
||||||
"nginx",
|
"nginx",
|
||||||
"php5-fpm",
|
|
||||||
"mysql"
|
"mysql"
|
||||||
],
|
],
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"install": [{
|
"install": [{
|
||||||
"name": "domain",
|
"name": "domain",
|
||||||
"type": "domain",
|
"type": "domain",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a domain name for Scratch",
|
|
||||||
"fr": "Choisissez un nom de domaine pour Scratch"
|
|
||||||
},
|
|
||||||
"example": "example.com"
|
"example": "example.com"
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"name": "path",
|
"name": "path",
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"ask": {
|
|
||||||
"en": "Choose a path for Scratch /scratch is accepted",
|
|
||||||
"fr": "Choisissez un chemin pour Scratch /scratch est accepté"
|
|
||||||
},
|
|
||||||
"example": "/scratch",
|
"example": "/scratch",
|
||||||
"default": "/scratch"
|
"default": "/scratch"
|
||||||
},
|
},
|
||||||
|
@ -47,11 +38,7 @@
|
||||||
{
|
{
|
||||||
"name": "is_public",
|
"name": "is_public",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"ask": {
|
"default": true
|
||||||
"en": "Is it a public site ?",
|
|
||||||
"fr": "Est-ce un site public ?"
|
|
||||||
},
|
|
||||||
"default": "true"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,112 +1,20 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# =============================================================================
|
#=================================================
|
||||||
# YUNOHOST 2.7 FORTHCOMING HELPERS
|
# COMMON VARIABLES
|
||||||
# =============================================================================
|
#=================================================
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# dependencies used by the app
|
||||||
#
|
pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
|
||||||
# usage: ynh_add_nginx_config
|
|
||||||
ynh_add_nginx_config () {
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalnginxconf"
|
|
||||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
#=================================================
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
# PERSONAL HELPERS
|
||||||
if test -n "${path_url:-}"; then
|
#=================================================
|
||||||
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${domain:-}"; then
|
|
||||||
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${port:-}"; then
|
|
||||||
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${app:-}"; then
|
|
||||||
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
if test -n "${final_path:-}"; then
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
|
|
||||||
fi
|
|
||||||
ynh_store_file_checksum "$finalnginxconf"
|
|
||||||
|
|
||||||
sudo systemctl reload nginx
|
#=================================================
|
||||||
}
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# Remove the dedicated nginx config
|
#=================================================
|
||||||
#
|
# FUTURE OFFICIAL HELPERS
|
||||||
# usage: ynh_remove_nginx_config
|
#=================================================
|
||||||
ynh_remove_nginx_config () {
|
|
||||||
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
|
|
||||||
sudo systemctl reload nginx
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
|
||||||
#
|
|
||||||
# usage: ynh_add_fpm_config
|
|
||||||
ynh_add_fpm_config () {
|
|
||||||
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalphpconf"
|
|
||||||
sudo cp ../conf/php-fpm.conf "$finalphpconf"
|
|
||||||
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
|
|
||||||
ynh_replace_string "__USER__" "$app" "$finalphpconf"
|
|
||||||
sudo chown root: "$finalphpconf"
|
|
||||||
ynh_store_file_checksum "$finalphpconf"
|
|
||||||
|
|
||||||
if [ -e "../conf/php-fpm.ini" ]
|
|
||||||
then
|
|
||||||
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalphpini"
|
|
||||||
sudo cp ../conf/php-fpm.ini "$finalphpini"
|
|
||||||
sudo chown root: "$finalphpini"
|
|
||||||
ynh_store_file_checksum "$finalphpini"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo systemctl reload php5-fpm
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove the dedicated php-fpm config
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_fpm_config
|
|
||||||
ynh_remove_fpm_config () {
|
|
||||||
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
|
|
||||||
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1
|
|
||||||
sudo systemctl reload php5-fpm
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
#
|
|
||||||
# usage: ynh_add_systemd_config
|
|
||||||
ynh_add_systemd_config () {
|
|
||||||
finalsystemdconf="/etc/systemd/system/$app.service"
|
|
||||||
ynh_backup_if_checksum_is_different "$finalsystemdconf"
|
|
||||||
sudo cp ../conf/systemd.service "$finalsystemdconf"
|
|
||||||
|
|
||||||
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
|
|
||||||
# Substitute in a nginx config file only if the variable is not empty
|
|
||||||
if test -n "${final_path:-}"; then
|
|
||||||
ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
|
|
||||||
fi
|
|
||||||
if test -n "${app:-}"; then
|
|
||||||
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
|
|
||||||
fi
|
|
||||||
ynh_store_file_checksum "$finalsystemdconf"
|
|
||||||
|
|
||||||
sudo chown root: "$finalsystemdconf"
|
|
||||||
sudo systemctl enable $app
|
|
||||||
sudo systemctl daemon-reload
|
|
||||||
}
|
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
|
||||||
#
|
|
||||||
# usage: ynh_remove_systemd_config
|
|
||||||
ynh_remove_systemd_config () {
|
|
||||||
finalsystemdconf="/etc/systemd/system/$app.service"
|
|
||||||
if [ -e "$finalsystemdconf" ]; then
|
|
||||||
sudo systemctl stop $app
|
|
||||||
sudo systemctl disable $app
|
|
||||||
ynh_secure_remove "$finalsystemdconf"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,33 +1,55 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
# See comments in install script
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
source ../settings/scripts/_common.sh
|
||||||
|
|
||||||
# Source YunoHost helpers
|
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
# Backup sources & data
|
#=================================================
|
||||||
# Note: the last argument is where to save this path, see the restore script.
|
# MANAGE SCRIPT FAILURE
|
||||||
ynh_backup "/var/www/${app}" "sources"
|
#=================================================
|
||||||
|
|
||||||
### MySQL (remove if not used) ###
|
ynh_clean_setup () {
|
||||||
# If a MySQL database is used:
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
# # Dump the database
|
true
|
||||||
# dbname=$app
|
}
|
||||||
# dbuser=$app
|
# Exit if an error occurs during the execution of the script
|
||||||
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
ynh_abort_if_errors
|
||||||
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
|
|
||||||
### MySQL end ###
|
|
||||||
|
|
||||||
# Copy NGINX configuration
|
#=================================================
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
# LOAD SETTINGS
|
||||||
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf"
|
#=================================================
|
||||||
|
ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
### PHP (remove if not used) ###
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
# If a dedicated php-fpm process is used:
|
|
||||||
# # Copy PHP-FPM pool configuration
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf"
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
### PHP end ###
|
|
||||||
|
#=================================================
|
||||||
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
|
@ -29,57 +29,35 @@ domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url=$YNH_APP_ARG_PATH
|
path_url=$YNH_APP_ARG_PATH
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
|
||||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
|
||||||
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
|
||||||
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
|
||||||
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
|
||||||
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
|
||||||
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
|
||||||
### The app instance name is probably what interests you most, since this is
|
|
||||||
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
|
||||||
### db names, ...
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app".
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app"
|
|
||||||
final_path=/var/www/$app
|
final_path=/var/www/$app
|
||||||
test ! -e "$final_path" || ynh_die "This path already contains a folder"
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
# Normalize the url path syntax
|
|
||||||
path_url=$(ynh_normalize_url_path $path_url)
|
|
||||||
|
|
||||||
# Check web path availability
|
|
||||||
ynh_webpath_available $domain $path_url
|
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Storing installation settings..." --weight=1
|
||||||
|
|
||||||
ynh_app_setting_set $app domain $domain
|
ynh_app_setting_set --app=$app --key=domain --value=$domain
|
||||||
ynh_app_setting_set $app path $path_url
|
ynh_app_setting_set --app=$app --key=path --value=$path_url
|
||||||
ynh_app_setting_set $app is_public $is_public
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### Use these lines if you have to open a port for the application
|
|
||||||
### `ynh_find_port` will find the first available port starting from the given port.
|
|
||||||
### If you're not using these lines:
|
|
||||||
### - Remove the section "CLOSE A PORT" in the remove script
|
|
||||||
|
|
||||||
# Find a free port
|
# Find a free port
|
||||||
port=$(ynh_find_port 80)
|
port=$(ynh_find_port 80)
|
||||||
# Open this port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
#yunohost firewall allow --no-upnp TCP $port 2>&1
|
|
||||||
ynh_app_setting_set $app port $port
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
@ -103,48 +81,27 @@ ynh_add_nginx_config
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create $app
|
ynh_system_user_create $app
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# MODIFY A CONFIG FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
#ynh_replace_string "__DOMAIN__" "$domain" "../conf/nginx.conf"
|
|
||||||
#cp -a ../conf/streama.service /etc/systemd/system/streama.service
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### `ynh_store_file_checksum` is used to store the checksum of a file.
|
|
||||||
### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`,
|
|
||||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
|
||||||
#ynh_store_file_checksum "/etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf"
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# SECURE FILES AND DIRECTORIES
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### For security reason, any app should set the permissions to root: before anything else.
|
|
||||||
### Then, if write authorization is needed, any access should be given only to directories
|
|
||||||
### that really need such authorization.
|
|
||||||
|
|
||||||
# Set permissions to app files
|
|
||||||
#chown -R admin:1007 /opt/streama
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
# Make app public if necessary
|
||||||
if [ $is_public -eq 1 ]; then
|
if [ $is_public -eq 1 ]
|
||||||
# unprotected_uris allows SSO credentials to be passed anyway.
|
then
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload services
|
#=================================================
|
||||||
systemctl reload nginx
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
|
|
||||||
|
|
|
@ -12,26 +12,29 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
domain=$(ynh_app_setting_get $app domain)
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
port=$(ynh_app_setting_get $app port)
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
||||||
final_path=$(ynh_app_setting_get $app final_path)
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --time --weight=1
|
||||||
|
|
||||||
#ynh_package_remove emby-server
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEPENDENCIES
|
# REMOVE NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
# Remove the dedicated NGINX config
|
||||||
#ynh_remove_app_dependencies
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -46,37 +49,18 @@ ynh_secure_remove "$final_path"
|
||||||
# Remove the dedicated nginx config
|
# Remove the dedicated nginx config
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CLOSE A PORT
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
|
||||||
then
|
|
||||||
echo "Close port $port" >&2
|
|
||||||
yunohost firewall disallow TCP $port 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC REMOVE
|
|
||||||
#=================================================
|
|
||||||
# REMOVE THE CRON FILE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Remove a cron file
|
|
||||||
ynh_secure_remove "/etc/cron.d/$app"
|
|
||||||
|
|
||||||
# Remove a directory securely
|
|
||||||
ynh_secure_remove "/etc/systemd/system/streama.service"
|
|
||||||
|
|
||||||
|
|
||||||
# Remove the log files
|
|
||||||
ynh_secure_remove "/var/log/$app/"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE DEDICATED USER
|
# REMOVE DEDICATED USER
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1
|
||||||
|
|
||||||
# Delete a system user
|
# Delete a system user
|
||||||
ynh_system_user_delete $app
|
ynh_system_user_delete --username=$app
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --time --last
|
||||||
|
|
117
scripts/upgrade
117
scripts/upgrade
|
@ -1,57 +1,98 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Exit on command errors and treat unset variables as an error
|
#=================================================
|
||||||
set -eu
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
# See comments in install script
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
# Source YunoHost helpers
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
source /usr/share/yunohost/helpers
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
source _common.sh
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
# Retrieve app settings
|
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
|
||||||
password=$(ynh_app_setting_get "$app" password)
|
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
||||||
nextclouddomain=$(ynh_app_setting_get "$app" nextclouddomain)
|
|
||||||
|
|
||||||
|
|
||||||
# Set permissions to app files
|
|
||||||
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
|
||||||
sudo chown -R root: $src_path
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE COLLABORA
|
# CHECK VERSION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_package_update
|
|
||||||
ynh_install_app_dependencies loolwsd code-brand
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||||
|
|
||||||
|
# Cleaning legacy permissions
|
||||||
|
if ynh_legacy_permissions_exists; then
|
||||||
|
ynh_legacy_permissions_delete_all
|
||||||
|
|
||||||
|
ynh_app_setting_delete --app=$app --key=is_public
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CREATE DEDICATED USER
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated user (if not existing)
|
||||||
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
chmod 750 "$final_path"
|
||||||
|
chmod -R o-rwx "$final_path"
|
||||||
|
chown -R $app:www-data "$final_path"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated NGINX config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE CONFIG
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
cp -a ../conf/loolwsd.xml /etc/loolwsd
|
|
||||||
ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml"
|
|
||||||
ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml"
|
|
||||||
systemctl restart loolwsd
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# If app is public, add url to SSOWat conf as skipped_uris
|
|
||||||
if [[ $is_public -eq 1 ]]; then
|
|
||||||
# See install script
|
|
||||||
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Reload nginx service
|
|
||||||
systemctl restart nginx
|
|
||||||
systemctl restart loolwsd
|
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||||
|
|
Loading…
Reference in a new issue