From 74d66d70e06122358c903659f9f2cf3cd45c5ac7 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 6 Apr 2021 08:58:51 +0200 Subject: [PATCH] Update upgrade --- scripts/upgrade | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c395b34..09d8156 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,8 +72,23 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -a "$final_path/config.json" "$tmpdir/config.json" + + # Remove the app directory securely + ynh_secure_remove --file="$final_path" + # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/config.json" "$final_path/config.json" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi #================================================= @@ -107,12 +122,6 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# UPDATE A CONFIG FILE -#================================================= - -ynh_add_config --template="../conf/config.json" --destination="$final_path/config.json" - #================================================= # GENERIC FINALIZATION #=================================================