From a0b58f57964f2d4960029f229194149e2a40a252 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Mon, 13 Sep 2021 14:32:13 +0200 Subject: [PATCH] Apply example_ynh --- scripts/install | 2 +- scripts/restore | 16 ++++++++-------- scripts/upgrade | 36 ++++++++++++++++++------------------ 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/install b/scripts/install index b367332..97fa533 100644 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_add_nginx_config ynh_script_progression --message="Configuring system user..." --weight=2 # Create a system user -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # PHP-FPM CONFIGURATION diff --git a/scripts/restore b/scripts/restore index f1a1bd4..97d21ed 100644 --- a/scripts/restore +++ b/scripts/restore @@ -45,6 +45,14 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -61,14 +69,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - #================================================= # RESTORE USER RIGHTS #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b670943..c657130 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,20 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up Rainloop before upgrading (may take a while)..." --weight=4 + +# 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 #================================================= @@ -73,18 +87,12 @@ if ynh_legacy_permissions_exists; then fi #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Backing up Rainloop 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 @@ -115,14 +123,6 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=1 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 #=================================================