From 7888700cf5e1a3691a35d6829132680e01d14e19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Thu, 20 Jun 2024 22:31:02 +0200 Subject: [PATCH] cleaning --- conf/nginx.conf | 2 +- manifest.toml | 3 ++- scripts/backup | 14 +++++++------- scripts/change_url | 6 +++--- scripts/config | 6 +++--- scripts/install | 38 ++++++++------------------------------ scripts/remove | 14 ++++---------- scripts/restore | 36 +++++++++++------------------------- scripts/upgrade | 39 +++++---------------------------------- 9 files changed, 44 insertions(+), 114 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 883e762..ff328d3 100755 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -14,7 +14,7 @@ location __PATH__/ { 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-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/manifest.toml b/manifest.toml index cb10eed..5edc791 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,8 @@ userdoc = "https://omeka.org/s/docs/user-manual/" code = "https://github.com/omeka/omeka-s" [integration] -yunohost = ">= 11.2" +yunohost = ">= 11.2.15" +helpers_version = "2.1" architectures = "all" multi_instance = true diff --git a/scripts/backup b/scripts/backup index 30f2c81..fe74c2b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -13,31 +13,31 @@ 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 --message="Backing up the MySQL database..." +ynh_print_info "Backing up the MySQL database..." -ynh_mysql_dump_db --database="$db_name" > db.sql +ynh_mysql_dump_db > db.sql #================================================= # END OF SCRIPT #================================================= -ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index ab2d658..f282383 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -11,12 +11,12 @@ 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/config b/scripts/config index 91c2de7..23a8f38 100644 --- a/scripts/config +++ b/scripts/config @@ -15,8 +15,8 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS #================================================= -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) -current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) +php_version=$(ynh_app_setting_get --key=php_version) +current_fpm_footprint=$(ynh_app_setting_get --key=fpm_footprint) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY @@ -89,7 +89,7 @@ ynh_app_config_validate() { ynh_app_config_apply() { _ynh_app_config_apply - ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint + ynh_add_fpm_config --phpversion=$php_version --usage=$fpm_usage --footprint=$fpm_footprint } ynh_app_config_run $1 diff --git a/scripts/install b/scripts/install index e91476b..f87b631 100755 --- a/scripts/install +++ b/scripts/install @@ -1,34 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -fpm_footprint="low" -fpm_free_footprint=0 -fpm_usage="low" - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= - -ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint -ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint -ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression "Setting up source files..." ynh_setup_source --dest_dir="$install_dir" ynh_setup_source --dest_dir="$install_dir/modules/" --source_id="csvimport" @@ -39,20 +17,20 @@ chown -R $app:www-data "$install_dir" #================================================= # 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 PHP-FPM config -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +ynh_config_add_phpfpm # Create a dedicated NGINX config -ynh_add_nginx_config +ynh_config_add_nginx #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression "Adding a configuration file..." -ynh_add_config --template="database.ini.default" --destination="$install_dir/config/database.ini" +ynh_config_add --template="database.ini.default" --destination="$install_dir/config/database.ini" chmod 400 "$install_dir/config/database.ini" chown $app "$install_dir/config/database.ini" @@ -60,7 +38,7 @@ chown $app "$install_dir/config/database.ini" #================================================= # TWEAK IMAGICK CONFIGURATION TO ALLOW PDF THUMBNAILS GENERATION #================================================= -ynh_script_progression --message="Tweaking ImageMagick conf to allow generation of thumbnails PDF" --weight=1 +ynh_script_progression "Tweaking ImageMagick conf to allow generation of thumbnails PDF" sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml @@ -68,4 +46,4 @@ sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 1bd1d47..50486aa 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,25 +1,19 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 +ynh_script_progression "Removing system configurations related to $app..." -ynh_remove_nginx_config +ynh_config_remove_nginx -ynh_remove_fpm_config +ynh_config_remove_phpfpm #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 8aad9e9..0660040 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,26 +1,13 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# 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 -#================================================= -# LOAD SETTINGS -#================================================= - -fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) -fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) - #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=5 +ynh_script_progression "Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" @@ -30,23 +17,23 @@ 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 SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 +ynh_script_progression "Restoring system configurations related to $app..." -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" #================================================= # TWEAK IMAGICK CONFIGURATION TO ALLOW PDF THUMBNAILS GENERATION #================================================= -ynh_script_progression --message="Tweaking imagemagick conf to allow generation of thumbnails PDF" --weight=1 +ynh_script_progression "Tweaking imagemagick conf to allow generation of thumbnails PDF" sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml @@ -55,14 +42,13 @@ sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 +ynh_script_progression "Reloading NGINX web server and $app's service..." -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 16e1328..29b55e5 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,37 +1,8 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# If fpm_footprint doesn't exist, create it -if [ -z "${fpm_footprint:-}" ]; then - fpm_footprint=low - ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint -fi - -# If fpm_free_footprint doesn't exist, create it -if [ -z "${fpm_free_footprint:-}" ]; then - fpm_free_footprint=0 - ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint -fi - -# If fpm_usage doesn't exist, create it -if [ -z "${fpm_usage:-}" ]; then - fpm_usage=low - ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -47,16 +18,16 @@ chown -R $app:www-data "$install_dir" #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 +ynh_script_progression "Upgrading system configurations related to $app..." -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +ynh_config_add_phpfpm -ynh_add_nginx_config +nh_config_add_nginx #================================================= # TWEAK IMAGICK CONFIGURATION TO ALLOW PDF THUMBNAILS GENERATION #================================================= -ynh_script_progression --message="Tweaking ImageMagick conf to allow generation of thumbnails PDF" --weight=1 +ynh_script_progression "Tweaking ImageMagick conf to allow generation of thumbnails PDF" sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml @@ -64,4 +35,4 @@ sed -i 's/^\s*/g' /etc/ImageMagick-*/policy.xml # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression "Upgrade of $app completed"