From d6bf4ba4d691512d7d903ce1ecbe4d20c0c934b1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Jun 2022 19:19:38 +0200 Subject: [PATCH] Apply example_ynh --- check_process | 7 +++++-- conf/app.src | 2 ++ conf/systemd.service | 2 +- scripts/backup | 2 +- scripts/change_url | 2 ++ scripts/install | 3 +++ scripts/remove | 2 +- scripts/restore | 16 ++++++++-------- scripts/upgrade | 16 ++++++++-------- 9 files changed, 31 insertions(+), 21 deletions(-) diff --git a/check_process b/check_process index 78fc26a..49086e5 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ -;; Nom du test - auto_remove=1 +;; Test complet ; Manifest domain="domain.tld" path="/path" @@ -18,7 +17,11 @@ upgrade=1 from_commit=23e84578464b1fa09f79c98b6a9b5f19bbcf83f3 backup_restore=1 multi_instance=1 + port_already_use=0 change_url=1 +;;; Options +Email= +Notification=none ;;; Upgrade options ; commit=23e84578464b1fa09f79c98b6a9b5f19bbcf83f3 name=Merge pull request #35 from YunoHost-Apps/fix-buster diff --git a/conf/app.src b/conf/app.src index 795afb9..1294ebf 100644 --- a/conf/app.src +++ b/conf/app.src @@ -3,3 +3,5 @@ SOURCE_SUM=bd8146e6062fb180897544c27f862b5de56840e3fe7cde41824538f1de55a2b6 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/conf/systemd.service b/conf/systemd.service index 560d102..259d082 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -8,7 +8,7 @@ After=network.target Type=forking User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__FINALPATH__/ PIDFile=__FINALPATH__/script/hypnotoad.pid ExecStart=/usr/bin/carton exec hypnotoad script/lufi ExecStop=/usr/bin/carton exec hypnotoad -s script/lufi diff --git a/scripts/backup b/scripts/backup index dbd2762..f50339b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + true } # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/change_url b/scripts/change_url index cb2f20c..7f21894 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -46,6 +46,7 @@ ynh_script_progression --message="Backing up the app before changing its URL (ma # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" @@ -142,6 +143,7 @@ chown $app:$app $final_path/lufi.conf #================================================= ynh_script_progression --message="Starting a systemd service..." +# Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="$final_path/log/production.log" --line_match="Creating process id file" #================================================= diff --git a/scripts/install b/scripts/install index 6f2d44e..85e4c9e 100644 --- a/scripts/install +++ b/scripts/install @@ -195,8 +195,11 @@ ynh_systemd_action --service_name=$app --action="start" --line_match="Creating p #================================================= ynh_script_progression --message="Configuring permissions..." +# Make app public if necessary if [ $is_public -eq 1 ] then + # Everyone can access the app. + # The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" fi diff --git a/scripts/remove b/scripts/remove index 61cf84f..f7d2e34 100644 --- a/scripts/remove +++ b/scripts/remove @@ -57,7 +57,7 @@ ynh_remove_logrotate 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" +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index 17d0466..7fc5f5f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -44,13 +44,6 @@ test ! -d $final_path \ #================================================= # STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring NGINX configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -80,6 +73,13 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring the NGINX web server configuration..." + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 006df5d..f347ec9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,7 +56,7 @@ ynh_abort_if_errors #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action=stop --log_path="$final_path/log/production.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="$final_path/log/production.log" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -137,6 +137,13 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -145,13 +152,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." - -ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies - #================================================= # SPECIFIC UPGRADE #=================================================