From c35a032a51d9e6147acdb1a460d94ee4b6d8e4c1 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Sun, 23 Jun 2024 09:20:53 +0200 Subject: [PATCH 1/7] helpers v2.1 + fix bookworm --- conf/nginx.conf | 2 +- manifest.toml | 3 ++- scripts/backup | 17 +++++------------ scripts/change_url | 10 +++------- scripts/install | 25 +++++++++++-------------- scripts/remove | 12 ++++-------- scripts/restore | 26 +++++++++++--------------- scripts/upgrade | 14 +++++--------- tests.toml | 2 +- 9 files changed, 43 insertions(+), 68 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index c63d69d..5ffaa64 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,7 +12,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock; fastcgi_index index.php; include fastcgi_params; diff --git a/manifest.toml b/manifest.toml index dca2535..ed5c175 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,8 @@ admindoc = "https://wiki.webtrees.net" code = "https://github.com/fisharebest/webtrees" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.15" +helpers_version = "2.1" architectures = "all" multi_instance = true ldap = false diff --git a/scripts/backup b/scripts/backup index f5a97a9..a639fa7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,37 +1,30 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# DECLARE DATA AND CONF FILES TO BACKUP -#================================================= -ynh_print_info --message="Declaring files to be backed up..." +ynh_print_info "Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$install_dir" +ynh_backup "$install_dir" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= ynh_print_info "Backing up the MySQL database..." -ynh_mysql_dump_db "$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index cfcb0d6..39d37fc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,21 +1,17 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +ynh_script_progression "Updating NGINX web server configuration..." -ynh_change_url_nginx_config +ynh_config_change_url_nginx #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --last +ynh_script_progression "Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index 21cc7a7..6f62cc5 100755 --- a/scripts/install +++ b/scripts/install @@ -1,9 +1,5 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -11,7 +7,7 @@ source /usr/share/yunohost/helpers # INITIALIZE AND STORE SETTINGS #================================================= -admin_password=$(ynh_string_random 24) +admin_password=$(ynh_string_random --length=24) admin_password_hashed=$(mkpasswd -m md5crypt --stdin <<< "$admin_password") ynh_app_setting_set --app="$app" --key="admin_password" --value="$admin_password" @@ -19,7 +15,7 @@ ynh_app_setting_set --app="$app" --key="admin_password" --value="$admin_password #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression "Setting up source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" @@ -34,14 +30,15 @@ chown -R "$app:www-data" "$install_dir" ynh_script_progression --message="Adding $app's configuration files..." --weight=1 # Adding the details of the database to the config file -ynh_add_config --template="config.ini.php" --destination="$install_dir/data/config.ini.php" +ynh_config_add --template="config.ini.php" --destination="$install_dir/data/config.ini.php" # Load initial SQL into the new database -ynh_add_config --template="sql/webtrees.sql" --destination="$install_dir/webtrees.sql" -ynh_add_config --template="sql/admin.sql" --destination="$install_dir/admin.sql" +ynh_config_add --template="sql/webtrees.sql" --destination="$install_dir/webtrees.sql" +ynh_config_add --template="sql/admin.sql" --destination="$install_dir/admin.sql" -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/webtrees.sql" -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < "$install_dir/admin.sql" +# Load initial SQL into the new database +ynh_mysql_db_shell < "$install_dir/webtrees.sql" +ynh_mysql_db_shell < "$install_dir/admin.sql" ynh_secure_remove --file="$install_dir/webtrees.sql" ynh_secure_remove --file="$install_dir/admin.sql" @@ -52,13 +49,13 @@ ynh_secure_remove --file="$install_dir/admin.sql" ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 13ece6b..0201b35 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,25 +1,21 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression "Removing NGINX web server configuration..." # Remove the dedicated NGINX config -ynh_remove_nginx_config +ynh_config_remove_nginx # Remove the dedicated PHP-FPM config -ynh_remove_fpm_config +ynh_config_remove_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 6026dd1..aeca210 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,18 +1,14 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression "Restoring $app main directory..." -ynh_restore_file --origin_path="$install_dir" +ynh_restore "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" @@ -20,29 +16,29 @@ chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=1 +ynh_script_progression "Restoring the MySQL database..." -ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql +ynh_mysql_db_shell < ./db.sql #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weight=1 +ynh_script_progression "Restoring the PHP-FPM configuration..." -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" +ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression "Reloading NGINX web server and PHP-FPM..." -ynh_systemd_action --service_name="php${phpversion}-fpm" --action=reload -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemctl --service="php${php_version}-fpm" --action=reload +ynh_systemctl --service=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 6b4b862..7654af7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,9 +1,5 @@ #!/bin/bash -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers @@ -40,7 +36,7 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading source files..." +ynh_script_progression "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="data modules_v4" @@ -52,16 +48,16 @@ chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression"Upgrading system configurations related to $app..." # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_config_add_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed" diff --git a/tests.toml b/tests.toml index 42a573b..2e70e4c 100644 --- a/tests.toml +++ b/tests.toml @@ -16,4 +16,4 @@ test_format = 1.0 # Commits to test upgrade from # ------------------------------- - #test_upgrade_from.dfcde24cce4db0527465acbc16dcecf9a3082858.name = "2.1.16" + test_upgrade_from.9f28316.name = "helpers v1" From c06cf4d7db82330c768c17e943a6b34b44dfa9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:42:00 +0200 Subject: [PATCH 2/7] Update manifest.toml --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index ed5c175..039b3f8 100644 --- a/manifest.toml +++ b/manifest.toml @@ -19,7 +19,7 @@ admindoc = "https://wiki.webtrees.net" code = "https://github.com/fisharebest/webtrees" [integration] -yunohost = ">= 11.2.15" +yunohost = ">= 11.2.20" helpers_version = "2.1" architectures = "all" multi_instance = true From efbf4f216a484a343032be345addee4439098fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:43:09 +0200 Subject: [PATCH 3/7] cleaning --- scripts/install | 4 ++-- scripts/upgrade | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 6f62cc5..b670bcc 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ chown -R "$app:www-data" "$install_dir" #================================================= # APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +ynh_script_progression "Adding $app's configuration files..." # Adding the details of the database to the config file ynh_config_add --template="config.ini.php" --destination="$install_dir/data/config.ini.php" @@ -46,7 +46,7 @@ ynh_secure_remove --file="$install_dir/admin.sql" #================================================= # SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 +ynh_script_progression "Adding system configurations related to $app..." # Create a dedicated NGINX config ynh_config_add_nginx diff --git a/scripts/upgrade b/scripts/upgrade index 7654af7..c0f15a9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -6,7 +6,7 @@ source /usr/share/yunohost/helpers #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression "Ensuring downward compatibility..." # Migrate manifest questions if [ -z "${admin_username:-}" ]; then From 2dc2b82a85602ee4f2778c962b4adcc6c1e3b1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 1 Jul 2024 21:43:25 +0200 Subject: [PATCH 4/7] Update upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index c0f15a9..dd4003b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,7 +48,7 @@ chown -R "$app:www-data" "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression"Upgrading system configurations related to $app..." +ynh_script_progression "Upgrading system configurations related to $app..." # Create a dedicated NGINX config ynh_config_add_nginx From 2e2129413365ce59cf6312f80f37d85e7744551f Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:00:55 +0200 Subject: [PATCH 5/7] fixes some helpers_v2 stuffs --- scripts/install | 4 ++-- scripts/upgrade | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/scripts/install b/scripts/install index b670bcc..65f8c0e 100755 --- a/scripts/install +++ b/scripts/install @@ -40,8 +40,8 @@ ynh_config_add --template="sql/admin.sql" --destination="$install_dir/admin.sql" ynh_mysql_db_shell < "$install_dir/webtrees.sql" ynh_mysql_db_shell < "$install_dir/admin.sql" -ynh_secure_remove --file="$install_dir/webtrees.sql" -ynh_secure_remove --file="$install_dir/admin.sql" +ynh_safe-rm --file="$install_dir/webtrees.sql" +ynh_safe-rm --file="$install_dir/admin.sql" #================================================= # SYSTEM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index dd4003b..dd132c1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,26 +9,18 @@ source /usr/share/yunohost/helpers ynh_script_progression "Ensuring downward compatibility..." # Migrate manifest questions -if [ -z "${admin_username:-}" ]; then - admin_username="$username" - ynh_app_setting_set --app="$app" --key="admin_username" --value="$admin_username" -fi +ynh_app_setting_set_default --key=admin_username --value=$username +ynh_app_setting_set_default --key=admin_name --value=$name +ynh_app_setting_set_default --key=admin_email --value=$email + if [ -n "${username:-}" ]; then ynh_app_setting_delete --app="$app" --key="username" fi -if [ -z "${admin_name:-}" ]; then - admin_name="$name" - ynh_app_setting_set --app="$app" --key="admin_name" --value="$admin_name" -fi if [ -n "${name:-}" ]; then ynh_app_setting_delete --app="$app" --key="name" fi -if [ -z "${admin_email:-}" ]; then - admin_email="$email" - ynh_app_setting_set --app="$app" --key="admin_email" --value="$admin_email" -fi if [ -n "${email:-}" ]; then ynh_app_setting_delete --app="$app" --key="email" fi From 6db14c2e2738753c69d2b40295e0c6e468f31335 Mon Sep 17 00:00:00 2001 From: Thomas <51749973+Thovi98@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:31:31 +0200 Subject: [PATCH 6/7] fix variable typo --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 65f8c0e..88bfe2c 100755 --- a/scripts/install +++ b/scripts/install @@ -40,8 +40,8 @@ ynh_config_add --template="sql/admin.sql" --destination="$install_dir/admin.sql" ynh_mysql_db_shell < "$install_dir/webtrees.sql" ynh_mysql_db_shell < "$install_dir/admin.sql" -ynh_safe-rm --file="$install_dir/webtrees.sql" -ynh_safe-rm --file="$install_dir/admin.sql" +ynh_safe_rm --file="$install_dir/webtrees.sql" +ynh_safe_rm --file="$install_dir/admin.sql" #================================================= # SYSTEM CONFIGURATION From ec8a6599602528583af973ca6db0b442599fc68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:10:42 +0200 Subject: [PATCH 7/7] Update upgrade --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index dd132c1..a1777db 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,15 +14,15 @@ ynh_app_setting_set_default --key=admin_name --value=$name ynh_app_setting_set_default --key=admin_email --value=$email if [ -n "${username:-}" ]; then - ynh_app_setting_delete --app="$app" --key="username" + ynh_app_setting_delete --app="$app" --key="admin_username" fi if [ -n "${name:-}" ]; then - ynh_app_setting_delete --app="$app" --key="name" + ynh_app_setting_delete --app="$app" --key="admin_name" fi if [ -n "${email:-}" ]; then - ynh_app_setting_delete --app="$app" --key="email" + ynh_app_setting_delete --app="$app" --key="admin_email" fi #=================================================