From f4d9f40daf319a7046d68ada835881db8dfd5124 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 26 Jun 2022 07:50:56 +0200 Subject: [PATCH] Cleaning up --- scripts/install | 6 ------ scripts/restore | 3 ++- scripts/upgrade | 35 ++++++++++------------------------- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/scripts/install b/scripts/install index f0d7fc4..5074b60 100644 --- a/scripts/install +++ b/scripts/install @@ -123,12 +123,6 @@ chown $app "$final_path/server/config.js" #============================================== ynh_script_progression --message="Building $app... (this will take some time and resources!)" --weight=20 -#pushd "$final_path" -# ynh_use_nodejs -# ynh_exec_warn_less ynh_npm install -# ynh_exec_warn_less ynh_npm run build -#popd - pushd "$final_path" ynh_use_nodejs ynh_exec_warn_less ynh_exec_as $app env "$ynh_node_load_PATH" npm install diff --git a/scripts/restore b/scripts/restore index 557566d..1911c37 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,7 +35,8 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= ynh_script_progression --message="Validating restoration parameters..." --weight=2 -test ! -d $final_path || ynh_die --message="There is already a directory: $final_path " +test ! -d $final_path \ + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS diff --git a/scripts/upgrade b/scripts/upgrade index 051eb59..7f114f6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,6 +27,15 @@ port=$(ynh_app_setting_get --app=$app --key=port) upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -41,15 +50,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" - #================================================= # CREATE DEDICATED USER #================================================= @@ -66,23 +66,8 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=10 - # Create a temporary directory - tmpdir="$(mktemp -d)" - - # Backup the config file in the temp dir - cp -a "$final_path/server/config.js" "$tmpdir/config.js" - - # Remove the app directory securely - ynh_secure_remove --file=$final_path - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir=$final_path - - #Copy the admin saved settings from tmp directory to final path - cp -a "$tmpdir/config.js" "$final_path/server/config.js" - - # Remove the tmp directory securely - ynh_secure_remove --file="$tmpdir" + ynh_setup_source --dest_dir=$final_path --keep="$final_path/server/config.js" fi chmod 750 "$final_path"