From 6b2279292ceceeb6d19a277eac010735c681a961 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 21 Jan 2022 02:01:46 +0100 Subject: [PATCH] upgrade to 0.7.1~ynh1 --- check_process | 4 ++++ conf/arm64.src | 4 ++-- conf/systemd.service | 1 - scripts/install | 2 +- scripts/remove | 44 ++++++++++++++++++------------------ scripts/restore | 19 ++++++++-------- scripts/upgrade | 53 ++++++++++++++++++++++---------------------- 7 files changed, 66 insertions(+), 61 deletions(-) diff --git a/check_process b/check_process index 06c8904..831c31e 100755 --- a/check_process +++ b/check_process @@ -22,6 +22,8 @@ upgrade=1 from_commit=457f1dd7719286f28755d9561133a8e176be63c7 # 0.6.0~ynh1 upgrade=1 from_commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3 + # 0.6.0~ynh2 + upgrade=1 from_commit=583e101b12a081c45bee50df9068e606b5983bb2 backup_restore=1 multi_instance=1 port_already_use=0 @@ -38,3 +40,5 @@ Notification=none name=0.5.0~ynh1 ; commit=0f9c1c6e3c151e94e5f53b1464aec732334209a3 name=0.6.0~ynh1 + ; commit=583e101b12a081c45bee50df9068e606b5983bb2 + name=0.6.0~ynh2 diff --git a/conf/arm64.src b/conf/arm64.src index 19c4291..b03a1b4 100644 --- a/conf/arm64.src +++ b/conf/arm64.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/YunoHost-Apps/plume_ynh/releases/download/0.6.0/plume-arm64-postgres.tar.gz -SOURCE_SUM=c821052f0d7c6cbb2d4eeffd143fb36b3add30b57c4bfc442d6604bd43e2f1b2 +SOURCE_URL=https://github.com/YunoHost-Apps/plume_ynh/releases/download/0.7.1/plume-arm64-postgres.tar.gz +SOURCE_SUM=872d074c492e43d391f0f932e921adc0916ed58bd6388aaa591c966ce962f8be SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=false diff --git a/conf/systemd.service b/conf/systemd.service index 4ea0196..7617069 100755 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -11,7 +11,6 @@ ExecStart=/bin/sh -c '__FINALPATH__/.cargo/bin/plume >> /var/log/__APP__/__APP__ TimeoutSec=30 Restart=always - # Sandboxing options to harden security # Depending on specificities of your service/app, you may need to tweak these # .. but this should be a good baseline diff --git a/scripts/install b/scripts/install index 29ab12c..2d0c1a2 100755 --- a/scripts/install +++ b/scripts/install @@ -90,7 +90,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies ynh_script_progression --message="Configuring system user..." # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE A POSTGRESQL DATABASE diff --git a/scripts/remove b/scripts/remove index eb4e008..5a4da68 100755 --- a/scripts/remove +++ b/scripts/remove @@ -43,6 +43,14 @@ ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= @@ -51,24 +59,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" - -pushd $final_path/$app - sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli -popd - -if [ -d "/usr/local/lib/rustlib" ]; then - sudo /usr/local/lib/rustlib/uninstall.sh -fi - #================================================= # REMOVE APP MAIN DIR #================================================= @@ -86,12 +76,22 @@ ynh_script_progression --message="Removing NGINX web server configuration..." ynh_remove_nginx_config #================================================= -# REMOVE LOGROTATE CONFIGURATION +# REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing logrotate configuration..." +ynh_script_progression --message="Removing dependencies..." -# Remove the app-specific logrotate config -ynh_remove_logrotate +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + +export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" + +pushd $final_path/$app + sudo -u "$app" env PATH=$PATH cargo uninstall diesel_cli +popd + +if [ -d "/usr/local/lib/rustlib" ]; then + sudo /usr/local/lib/rustlib/uninstall.sh +fi #================================================= # SPECIFIC REMOVE diff --git a/scripts/restore b/scripts/restore index 9d983e3..5975fa8 100755 --- a/scripts/restore +++ b/scripts/restore @@ -39,7 +39,8 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #================================================= ynh_script_progression --message="Validating restoration parameters..." -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 @@ -56,7 +57,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE THE APP MAIN DIR @@ -104,6 +105,13 @@ ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the logrotate configuration..." + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= @@ -118,13 +126,6 @@ ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started plume" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 597b478..aca4ab1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,9 +30,34 @@ architecture=$YNH_ARCH #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app 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 + ynh_clean_check_starting +} +# 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..." + +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped plume" + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -65,37 +90,13 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $port fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app 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 - ynh_clean_check_starting -} -# 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..." - -ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" --line_match="Stopped plume" - #================================================= # 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 --home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -148,7 +149,7 @@ chown -R "$app":"$app" "/var/log/$app" #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a config file..." +ynh_script_progression --message="Updating a configuration file..." ynh_add_config --template="../conf/.env" --destination="$final_path/$app/.env"