diff --git a/scripts/upgrade b/scripts/upgrade index af4b4e6..8843332 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ fi if ynh_version_gt "0.77-2" "${previous_version}" ; then ynh_install_nodejs --nodejs_version="8.9.3" ynh_use_nodejs - + # Create a dedicated systemd config ynh_replace_string --match_string="__NODEJS__" --replace_string="$nodejs_use_version" --target_file="../conf/systemd.service" ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service" @@ -155,10 +155,25 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_print_info --message="Upgrading source files..." - - architecture=$(ynh_detect_arch) + + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the env file in the temp dir + cp -a "$final_path/.env" "$tmpdir/.env" + + # Remove the app directory securely + ynh_secure_remove --file="$final_path" + + architecture=$(ynh_detect_arch) # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" --source_id="$architecture" + + #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 #=================================================