From abed61dbf53d9a55b00c2d0e16f580cbf966da06 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 17 Mar 2025 02:06:33 +0100 Subject: [PATCH] Improve --- manifest.toml | 16 +++++++++------- scripts/backup | 15 +++++++++++++-- scripts/change_url | 5 +++++ scripts/install | 28 +++++++++++++++------------- scripts/remove | 4 ++++ scripts/restore | 16 +++++++++++++--- scripts/upgrade | 23 ++++++++++++++--------- tests.toml | 10 ++++++++++ 8 files changed, 83 insertions(+), 34 deletions(-) diff --git a/manifest.toml b/manifest.toml index f5229a1..e4260f9 100644 --- a/manifest.toml +++ b/manifest.toml @@ -1,3 +1,5 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + packaging_format = 2 id = "invoiceninja5" @@ -58,13 +60,13 @@ ram.runtime = "50M" [resources.sources] - [resources.sources.main] - url = "https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.56/invoiceninja.tar" - sha256 = "979498b1e5afffa8de305b919bd799ba6c6a2b343d5a82ce94f9f6b969a61b03" - format = "tar.gz" - in_subdir = false - autoupdate.strategy = "latest_github_release" - autoupdate.asset = "invoiceninja.tar$" + [resources.sources.main] + url = "https://github.com/invoiceninja/invoiceninja/releases/download/v5.11.56/invoiceninja.tar" + sha256 = "979498b1e5afffa8de305b919bd799ba6c6a2b343d5a82ce94f9f6b969a61b03" + format = "tar.gz" + in_subdir = false + autoupdate.strategy = "latest_github_release" + autoupdate.asset = "invoiceninja.tar$" [resources.system_user] diff --git a/scripts/backup b/scripts/backup index 93e6628..3c5380e 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,5 +1,10 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -12,12 +17,18 @@ ynh_print_info "Declaring files to be backed up..." ynh_backup "$install_dir" #================================================= -# SYSTEM CONFIGURATION +# BACKUP SYSTEM CONFIGURATION #================================================= +# Backup the PHP-FPM configuration +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" + +# Backup the NGINX configuration ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" +#================================================= +# BACKUP VARIOUS FILES +#================================================= ynh_backup "/etc/cron.d/$app" diff --git a/scripts/change_url b/scripts/change_url index 0bce995..18aa6c9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers @@ -8,6 +12,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression "Updating NGINX web server configuration..." +# this will most likely adjust NGINX config correctly ynh_config_change_url_nginx #================================================= diff --git a/scripts/install b/scripts/install index 9d12244..63a30ed 100755 --- a/scripts/install +++ b/scripts/install @@ -1,10 +1,14 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers #================================================= -# GENERATE KEYS AND RETRIEVE ADMIN USER INFO +# INITIALIZE AND STORE SETTINGS #================================================= api_secret="$(ynh_string_random --length=32)" @@ -14,11 +18,6 @@ phantomjs_key="$(ynh_string_random --length=32)" email_fullname="$(ynh_user_get_info --username=$admin --key=fullname)" email="$(ynh_user_get_info --username=$admin --key=mail)" -#================================================= -# STORE KEYS TO APP SETTINGS -#================================================= -ynh_script_progression "Storing secrets to app settings..." - ynh_app_setting_set --key=api_secret --value=$api_secret ynh_app_setting_set --key=app_key --value=$app_key ynh_app_setting_set --key=phantomjs_key --value=$phantomjs_key @@ -28,24 +27,27 @@ ynh_app_setting_set --key=phantomjs_key --value=$phantomjs_key #================================================= ynh_script_progression "Setting up source files..." +# Download, check integrity, uncompress and patch the source from manifest.toml ynh_setup_source --dest_dir="$install_dir" +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +ynh_script_progression "Adding $app's configuration files..." + +ynh_config_add --template="default.env" --destination="$install_dir/.env" + #================================================= # SYSTEM CONFIGURATION #================================================= ynh_script_progression "Adding system configurations related to $app..." +# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it) ynh_config_add_phpfpm +# Create a dedicated NGINX config using the conf/nginx.conf template ynh_config_add_nginx -#================================================= -# MODIFY A CONFIG FILE -#================================================= -ynh_script_progression "Updating configuration..." - -ynh_config_add --template="default.env" --destination="$install_dir/.env" - #================================================= # BUILD THE APPLICATION #================================================= diff --git a/scripts/remove b/scripts/remove index 9d4118b..57eefca 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index 37f11a1..8d37f59 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,5 +1,10 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -26,14 +31,19 @@ ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RESTORE VARIOUS FILES +#================================================= + ynh_restore "/etc/cron.d/$app" #================================================= -# RELOAD NGINX AND PHP-FPM +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression "Reloading NGINX web server and PHP-FPM..." +ynh_script_progression "Reloading NGINX web server and $app's service..." + +ynh_systemctl --service="php$php_version-fpm" --action=reload -ynh_systemctl --service=php$php_version-fpm --action=reload ynh_systemctl --service=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index a58183e..7f9821b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,12 +1,16 @@ #!/bin/bash +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + source _common.sh source /usr/share/yunohost/helpers #================================================= -# ENSURE BACKWARD COMPATIBILITY +# ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression "Ensuring backward compatibility..." +ynh_script_progression "Ensuring downward compatibility..." # Delete deprecated `firstname`/`lastname` settings. See upstream https://github.com/YunoHost/yunohost/pull/1516 ynh_app_setting_delete --key=email_firstname @@ -26,8 +30,16 @@ ynh_app_setting_set_default --key=phantomjs_key --value="$(ynh_string_random --l #================================================= ynh_script_progression "Upgrading source files..." +# Download, check integrity, uncompress and patch the source from manifest.toml ynh_setup_source --dest_dir="$install_dir" --full_replace --keep=".env public/storage" +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression "Updating $app's configuration files..." + +ynh_config_add --template="default.env" --destination="$install_dir/.env" + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= @@ -39,13 +51,6 @@ ynh_config_add_nginx ynh_config_add --template="cron" --destination="/etc/cron.d/$app" -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression "Updating configuration..." - -ynh_config_add --template="default.env" --destination="$install_dir/.env" - #================================================= # UPGRADE DATABASE #================================================= diff --git a/tests.toml b/tests.toml index 66e93d5..8829f31 100644 --- a/tests.toml +++ b/tests.toml @@ -1,7 +1,17 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + test_format = 1.0 [default] + # ------------ + # Tests to run + # ------------ + + # ------------------------------- + # Default args to use for install + # ------------------------------- + # ------------------------------- # Commits to test upgrade from # -------------------------------