diff --git a/manifest.json b/manifest.json index 1962914..5a91016 100644 --- a/manifest.json +++ b/manifest.json @@ -8,18 +8,17 @@ }, "url": "https://jappix.org/", "license": "AGPL-3", - "version": "1.1.7", + "version": "1.1.7~ynh1", "maintainer": { "name": "titoko", "email": "titoko@titoko.fr" }, "multi_instance": false, "requirements": { - "yunohost": ">> 2.3.15" + "yunohost": ">> 3.8.1" }, "services": [ - "nginx", - "php5-fpm", + "nginx" "metronome" ], "arguments": { diff --git a/scripts/.fonctions b/scripts/_common.sh similarity index 100% rename from scripts/.fonctions rename to scripts/_common.sh diff --git a/scripts/backup b/scripts/backup index f7d0cda..48e8fb6 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,18 +1,49 @@ #!/bin/bash -# causes the shell to exit if any subcommand or pipeline returns a non-zero status -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Source YNH helpers +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." + app=$YNH_APP_INSTANCE_NAME -# Retrieve app settings -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) -# Save sources & data -ynh_backup "/var/www/${app}" "sources" +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." -# Copy NGINX configuration -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +#================================================= +# 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)." diff --git a/scripts/install b/scripts/install index a85cd5f..9512cce 100644 --- a/scripts/install +++ b/scripts/install @@ -1,19 +1,19 @@ #!/bin/bash #================================================= -# GENERIC STARTING +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= -source .fonctions +source _common.sh source /usr/share/yunohost/helpers #================================================= # MANAGE FAILURE OF THE SCRIPT #================================================= -ynh_check_error # Active trap pour arrêter le script si une erreur est détectée. +ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST @@ -24,8 +24,8 @@ path=$YNH_APP_ARG_PATH name=$YNH_APP_ARG_NAME language=$YNH_APP_ARG_LANGUAGE - app=$YNH_APP_INSTANCE_NAME + #================================================= # Check domain/path availability #================================================= @@ -49,22 +49,22 @@ ynh_app_setting_set $app final_path $final_path SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path -sudo mkdir -p "${final_path}/store/conf" -sudo cp ../conf/*.xml "${final_path}/store/conf/" +mkdir -p "${final_path}/store/conf" +cp ../conf/*.xml "${final_path}/store/conf/" #================================================= # Set permissions to jappix directory #================================================= -sudo chown -R www-data: "$final_path" +chown -R www-data: "$final_path" #================================================= # Set and copy NGINX configuraion #================================================= -sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf -sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf +sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf +cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" #================================================= # Validate language @@ -77,12 +77,21 @@ sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # Set Jappix configuration #================================================= -sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" -sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" -sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" -sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" +sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" +sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" +sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" +sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" + #================================================= -# Reload services +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." -weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT #================================================= -sudo service nginx reload +ynh_script_progression --message="Installation of $app completed" --last + diff --git a/scripts/remove b/scripts/remove index da603b9..2ef80cf 100644 --- a/scripts/remove +++ b/scripts/remove @@ -3,6 +3,8 @@ set -u source /usr/share/yunohost/helpers +ynh_abort_if_errors + app=$YNH_APP_INSTANCE_NAME # Retrieve arguments diff --git a/scripts/restore b/scripts/restore index bffce4b..35aa320 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,19 +1,34 @@ #!/bin/bash -# causes the shell to exit if any subcommand or pipeline returns a non-zero status -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= + # Retrieve old app settings app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) - # Restore sources & data -sudo cp -a ./sources "/var/www/${app}" +cp -a ./sources "/var/www/${app}" # Restore Nginx and YunoHost parameters -sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # Reload services -sudo service nginx reload +service nginx reload diff --git a/scripts/upgrade b/scripts/upgrade index 4e4e187..e40c44f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,9 +1,19 @@ #!/bin/bash -set -eu -source .fonctions +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + app=$YNH_APP_INSTANCE_NAME # Récupère les infos de l'application. @@ -26,22 +36,33 @@ CHECK_PATH final_path="/var/www/${app}" ynh_app_setting_set $app final_path $final_path SETUP_SOURCE # Télécharge la source, décompresse et copie dans $final_path -sudo mkdir -p "${final_path}/store/conf" -sudo cp ../conf/*.xml "${final_path}/store/conf/" +mkdir -p "${final_path}/store/conf" +cp ../conf/*.xml "${final_path}/store/conf/" # Set permissions to jappix directory sudo chown -R www-data: "$final_path" # Set and copy NGINX configuraion -sudo sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf -sudo sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf +sed -i "s@ALIASTOCHANGE@${final_path}/@g" ../conf/nginx.conf +cp ../conf/nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" # Set Jappix configuration -sudo sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" -sudo sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" -sudo sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" -sudo sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" +sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml" +sed -i "s@CHANGELANG@${language}@g" "${final_path}/store/conf/main.xml" +sed -i "s@CHANGENAME@${name}@g" "${final_path}/store/conf/main.xml" +sed -i "s@DOMAINTOCHANGE@${domain}@g" "${final_path}/store/conf/hosts.xml" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last -# Reload services -sudo service nginx reload