From 493228004ccf4e8f1210cf240aeb2deadcb45853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 22 Jun 2021 08:40:39 +0200 Subject: [PATCH] Update upgrade (#33) --- scripts/upgrade | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d2a3103..a693c39 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -61,8 +61,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/.env" "$tmpdir/.env" + + # 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" --keep="$final_path/.env" + ynh_setup_source --dest_dir="$final_path" + + # Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/.env" "$final_path/.env" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi #=================================================