From 4d1e103cc99809b2b8c7d2634d133d3fc925a158 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 16 Apr 2019 03:42:47 +0200 Subject: [PATCH] Fix upgrade from previous version --- scripts/upgrade | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 47a7c7a..8d111d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,39 @@ sync_home=$(ynh_app_setting_get $app sync_home) sync_port=$(ynh_app_setting_get $app sync_port) gui_port=$(ynh_app_setting_get $app gui_port) +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_print_info "Ensuring downward compatibility..." + +# If gui_port doesn't exist, create it +if [ -z $gui_port ]; then + + OLD_SYNCHOME="/home/yunohost.app/syncthing" + OLD_SYNCUSER=debian-syncthing + OLD_SYNCPORT=22000 + OLD_GUIPORT=8384 + OLD_CONFIG="$OLD_SYNCHOME/.config/syncthing/config.xml" + + admin=$(ynh_app_setting_get $app allowed_users) + ynh_app_setting_set $app admin $admin + ynh_app_setting_delete --app="$app" --key="allowed_users" + + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path + + gui_port=$(grep -oP "
127.0.0.1:\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app gui_port $gui_port + + sync_home=$(grep -oP "\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app sync_home $gui_port + + sync_port=$(grep -oP "\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app sync_port $gui_port + + mkdir -p $final_path + cp -R $OLD_SYNCHOME/.config $final_path/.config +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -65,6 +98,14 @@ ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # CREATE DEDICATED USER #=================================================