From 146fe2942b8f2e928299fe7c5594d5662745970d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 22 Nov 2020 22:24:16 +0100 Subject: [PATCH] fix --- README.md | 2 +- manifest.json | 4 +++- scripts/install | 10 +++++----- scripts/upgrade | 46 +++++++++++++++++++++++++++++++++++++--------- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 876e87a..a029ecc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview Jappix is a fully-featured XMPP web-client with an open social platform which enables you to host your communication platform wherever you want to. -**Shipped version:** 1.1.7 +**Shipped version:** 1.2 #### Supported architectures diff --git a/manifest.json b/manifest.json index b5bf11d..6104730 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A free social network", "fr": "Un réseau social libre" }, - "version": "1.1.7~ynh1", + "version": "1.2~ynh1", "url": "https://jappix.org/", "license": "AGPL-3", "maintainer": { @@ -44,6 +44,7 @@ }, { "name": "name", + "type": "string", "ask": { "en": "Choose a name for Jappix", "fr": "Choisissez un nom pour Jappix" @@ -53,6 +54,7 @@ }, { "name": "language", + "type": "string", "ask": { "en": "Choose the default language of Jappix", "fr": "Choissisez la langue par défaut de Jappix" diff --git a/scripts/install b/scripts/install index 39b4def..fe0b5a6 100644 --- a/scripts/install +++ b/scripts/install @@ -84,15 +84,15 @@ ynh_add_nginx_config # Set Jappix configuration #================================================= -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" +sed -i "s@PATHTOCHANGE@${final_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..." -weight=1 +ynh_script_progression --message="Reloading NGINX web server..." -weight=1 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 31dfa68..4c6d22e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,12 +24,35 @@ path=$(ynh_app_setting_get $app path) name=$(ynh_app_setting_get "$app" name) language=$(ynh_app_setting_get "$app" language) -# Set default values -name="${name:-YunoJappix}" -language="${language:-en}" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..."--weight=1 -# Remove trailing "/" for next commands -CHECK_PATH +# Set default values +if [ -z "$language" ]; then + language="${language:-en}" + ynh_app_setting_set --app=$language --key=language --value=$language +fi + +if [ -z "$name" ]; then + name=${name:-YunoJappix} + ynh_app_setting_set --app=$app --key=name --value=$name +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --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 #================================================= # Copy files to the right place @@ -44,10 +67,15 @@ cp ../conf/*.xml "${final_path}/store/conf/" # Set permissions to jappix directory sudo chown -R www-data: "$final_path" -# Set and copy NGINX configuraion -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" +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + + # Set Jappix configuration sed -i "s@PATHTOCHANGE@${path}@g" "${final_path}/store/conf/hosts.xml"