From 26ec8394e8616e4fc84d3dd9738fe0074ea6923a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 28 Aug 2021 14:37:22 +0200 Subject: [PATCH] Update upgrade --- scripts/upgrade | 52 +++++++++---------------------------------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index fd697fc..3aa038b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -52,49 +52,6 @@ ynh_script_progression --message="Stopping a systemd service..." --time --weight ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 - -# -# N.B. : the followings setting migrations snippets are provided as *EXAMPLES* -# of what you may want to do in some cases (e.g. a setting was not defined on -# some legacy installs and you therefore want to initiaze stuff during upgrade) -# - -# If db_name doesn't exist, create it -#if [ -z "$db_name" ]; then -# db_name=$(ynh_sanitize_dbid --db_name=$app) -# ynh_app_setting_set --app=$app --key=db_name --value=$db_name -#fi - -# If final_path doesn't exist, create it -#if [ -z "$final_path" ]; then -# final_path=/var/www/$app -# ynh_app_setting_set --app=$app --key=final_path --value=$final_path -#fi - -### If nobody installed your app before 4.1, -### then you may safely remove these lines - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -if ! ynh_permission_exists --permission="admin"; then - # Create the required permissions - ynh_permission_create --permission="admin" --url="/admin" --allowed=$admin -fi - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - #================================================= # CREATE DEDICATED USER #================================================= @@ -110,9 +67,18 @@ ynh_system_user_create --username=$app --home_dir="$final_path" if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 + # Create a temporary directory + tmpdir="$(mktemp -d)" + cp -a "$final_path/inc/config.php" "$tmpdir/config.php" + + ynh_secure_remove --file="$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" + mv $final_path/Upload/* $final_path/ + ynh_secure_remove --file="$final_path/Documentation" + ynh_secure_remove --file="$final_path/Upload" + cp -a "$tmpdir/config.php" "$final_path/inc/config.php" fi chmod 750 "$final_path"