From d1a1295ed5eb0510002b30a3c0b815bcddfb82a8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 24 Apr 2024 18:26:52 +0200 Subject: [PATCH] Simplify the php fpm conf mess and other unecessarily verbose stuff --- scripts/backup | 22 ---------------- scripts/change_url | 10 -------- scripts/install | 37 ++++----------------------- scripts/remove | 10 ++------ scripts/restore | 10 +------- scripts/upgrade | 62 ++++++++-------------------------------------- 6 files changed, 18 insertions(+), 133 deletions(-) diff --git a/scripts/backup b/scripts/backup index 35afc88..cae3226 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,11 +1,5 @@ #!/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 @@ -15,28 +9,12 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# BACKUP THE APP MAIN DIR -#================================================= - ynh_backup --src_path="$install_dir" -#================================================= -# BACKUP THE NGINX CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# BACKUP THE PHP-FPM CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# BACKUP VARIOUS FILES -#================================================= - ynh_backup --src_path="/etc/cron.d/$app" #================================================= diff --git a/scripts/change_url b/scripts/change_url index 1fbf84a..fe39bca 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,18 +1,8 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" diff --git a/scripts/install b/scripts/install index 8f8534c..992cfea 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 -#================================================= - random_key=$(ynh_string_random --length=32) email=$(ynh_user_get_info --username=$admin --key=mail) timezone=$(cat /etc/timezone) - -fpm_footprint="low" -fpm_free_footprint=0 -fpm_usage="low" - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= - ynh_app_setting_set --app=$app --key=random_key --value=$random_key -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 @@ -42,11 +20,12 @@ chown -R $app:www-data "$install_dir" chmod -R 775 $install_dir/storage #================================================= -# PHP-FPM CONFIGURATION +# SYSTEL CONFIGURATIONS #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +ynh_script_progression --message="Add system configurations related to $app..." + +ynh_add_fpm_config ynh_add_nginx_config @@ -55,7 +34,7 @@ ynh_add_nginx_config #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression --message="Adding $app configuration..." ynh_add_config --template=".env" --destination="$install_dir/.env" @@ -74,12 +53,6 @@ ynh_exec_warn_less ynh_install_composer --phpversion=$phpversion --workdir=$inst #================================================= ynh_script_progression --message="Deploying..." -#pushd "$install_dir" -# php$phpversion artisan migrate:refresh --seed -# php$phpversion artisan firefly-iii:upgrade-database -# php$phpversion artisan passport:install -#popd - pushd "$install_dir" php$phpversion artisan firefly-iii:upgrade-database php$phpversion artisan firefly-iii:correct-database diff --git a/scripts/remove b/scripts/remove index 6a67d42..1c9db3a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,18 +1,12 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +ynh_script_progression --message="Removing configurations related to $app..." ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index 33d4b55..71a36d5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,11 +1,5 @@ #!/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 @@ -30,7 +24,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." +ynh_script_progression --message="Restoring configurations related to $app..." ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" @@ -43,8 +37,6 @@ chmod 644 "/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=php$phpversion-fpm --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 100978c..15dbb84 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,60 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - email=$(ynh_user_get_info --username=$admin --key=mail) timezone="$(cat /etc/timezone)" -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." - -# 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 #================================================= -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." +ynh_script_progression --message="Upgrading source files..." - ynh_setup_source --dest_dir="$install_dir" --keep=".env storage/upload storage/export" -fi +ynh_setup_source --dest_dir="$install_dir" --keep=".env storage/upload storage/export" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -65,7 +23,7 @@ chmod -R 775 $install_dir/storage #================================================= ynh_script_progression --message="Upgrading PHP-FPM configuration..." -ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint +ynh_add_fpm_config ynh_add_nginx_config @@ -94,13 +52,13 @@ ynh_exec_warn_less ynh_install_composer ynh_script_progression --message="Deploying..." pushd "$install_dir" - ynh_secure_remove --file="bootstrap/cache/*" - php$phpversion artisan migrate --seed - php$phpversion artisan firefly-iii:decrypt-all - php$phpversion artisan cache:clear - php$phpversion artisan firefly-iii:upgrade-database - php$phpversion artisan passport:keys || true - php$phpversion artisan cache:clear + ynh_secure_remove --file="bootstrap/cache/*" + php$phpversion artisan migrate --seed + php$phpversion artisan firefly-iii:decrypt-all + php$phpversion artisan cache:clear + php$phpversion artisan firefly-iii:upgrade-database + php$phpversion artisan passport:keys || true + php$phpversion artisan cache:clear popd #=================================================