diff --git a/scripts/upgrade b/scripts/upgrade index 413e1c5..1b5bdd2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -122,11 +122,28 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=2 + # Create a temporary directory + tmpdir="$(mktemp -d)" + + # Backup the config file and local plugins in the temp dir + cp -a "$final_path/config/config.json" "$tmpdir/config.json" + cp -ar "$final_path/plugins" "$tmpdir/plugins" + + # Remove the app directory securely + ynh_secure_remove --file="$final_path" + if [ "$version" = "Enterprise" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="enterprise" --keep="$final_path/plugins $final_path/config/config.json" + ynh_setup_source --dest_dir="$final_path" --source_id="enterprise" elif [ "$version" = "Team" ]; then - ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" --keep="$final_path/plugins $final_path/config/config.json" + ynh_setup_source --dest_dir="$final_path" --source_id="$YNH_ARCH" fi + + # Copy the admin saved settings and plugins from tmp directory to final path + cp -a "$tmpdir/config.json" "$final_path/config/config.json" + cp -ar --no-clobber "$tmpdir/plugins" "$final_path/" + + # Remove the tmp directory securely + ynh_secure_remove --file="$tmpdir" fi chmod 750 "$final_path"