From eec978c56051cd696f98e62aa420da70b18c892a Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 3 Apr 2022 10:38:11 +0200 Subject: [PATCH] Update upgrade --- scripts/upgrade | 56 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1475b4a..c187f83 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,6 +31,20 @@ password_hash=$(ynh_app_setting_get --app=$app --key=password_hash) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up Baïkal before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -61,18 +75,12 @@ if ! ynh_permission_exists --permission="admin"; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up Baïkal before upgrading (may take a while)..." --weight=4 +ynh_script_progression --message="Making sure dedicated system user exists..." -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # STANDARD UPGRADE STEPS @@ -85,19 +93,19 @@ then ynh_script_progression --message="Upgrading source files..." --weight=3 # Keep the Specific and config folders intact: https://sabre.io/baikal/upgrade/ - mkdir -p "$final_path/config" - temp_folder=$(mktemp -d) - mv "$final_path/Specific" "$temp_folder" - mv "$final_path/config" "$temp_folder" + #mkdir -p "$final_path/config" + #temp_folder=$(mktemp -d) + #mv "$final_path/Specific" "$temp_folder" + #mv "$final_path/config" "$temp_folder" # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$final_path" --keep="$final_path/Specific $final_path/config" - ynh_secure_remove --file="$final_path/Specific" - ynh_secure_remove --file="$final_path/config" + #ynh_secure_remove --file="$final_path/Specific" + #ynh_secure_remove --file="$final_path/config" - mv "$temp_folder/Specific" "$final_path" - mv "$temp_folder/config" "$final_path" - ynh_secure_remove --file="$temp_folder" + #mv "$temp_folder/Specific" "$final_path" + #mv "$temp_folder/config" "$final_path" + #ynh_secure_remove --file="$temp_folder" fi #================================================= @@ -115,14 +123,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # PHP-FPM CONFIGURATION #=================================================