diff --git a/scripts/upgrade b/scripts/upgrade index 5462c41..64dc9d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -71,6 +71,7 @@ ynh_print_info --message="Backing up the app before upgrading (may take a while) # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + read -p "key" # restore it if the upgrade fails ynh_restore_upgradebackup ynh_clean_check_starting @@ -94,9 +95,26 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file in the temp dir + cp -a "$final_path/$app/.env" "$tmpdir/.env" + cp -a "$final_path/$app/config/prod.exs" "$tmpdir/prod.exs" + + # Remove the app directory securely + ynh_secure_remove --file="$final_path/$app" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/$app" + + #Copy the admin saved settings from tmp directory to final path + cp -a "$tmpdir/.env" "$final_path/$app/.env" + cp -a "$tmpdir/prod.exs" "$final_path/$app/config/prod.exs" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi #=================================================