From 8df733cb88b43573ebaf32470a15b7207220fbed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Mon, 5 Jun 2023 11:03:43 +0200 Subject: [PATCH] cleaning --- scripts/change_url | 4 ++-- scripts/install | 12 ++++++------ scripts/remove | 6 ++++-- scripts/restore | 25 +++++++++++-------------- scripts/upgrade | 25 ++++++++++--------------- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index a411425..947011d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -12,7 +12,7 @@ source /usr/share/yunohost/helpers #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_change_url_nginx_config @@ -21,7 +21,7 @@ ynh_change_url_nginx_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_replace_string --match_string="$old_domain$old_path" --replace_string="$new_domain$new_path" --target_file="$final_path/.env" ynh_store_file_checksum --file="$final_path/.env" diff --git a/scripts/install b/scripts/install index 2bf4465..598c9e8 100755 --- a/scripts/install +++ b/scripts/install @@ -35,16 +35,16 @@ ynh_app_setting_set --app=$app --key=email --value=$email #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# PHP-FPM CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring PHP-FPM..." +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low @@ -57,7 +57,7 @@ ynh_add_nginx_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Modifying a config file..." --weight=1 ynh_add_config --template="default.env" --destination="$install_dir/.env" @@ -67,7 +67,7 @@ chown $app:$app "$install_dir/.env" #================================================= # BUILD THE APPLICATION #================================================= -ynh_script_progression --message="Building the application..." +ynh_script_progression --message="Building the application..." --weight=1 pushd "$install_dir" # Run the database migrations and initially fill the db @@ -89,7 +89,7 @@ chown -R $app:www-data "$install_dir" #================================================= # ADD A CRON JOB #================================================= -ynh_script_progression --message="Adding a cron job..." +ynh_script_progression --message="Adding a cron job..." --weight=1 ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" diff --git a/scripts/remove b/scripts/remove index d979ecc..8249abd 100755 --- a/scripts/remove +++ b/scripts/remove @@ -10,9 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# REMOVE NGINX CONFIGURATION +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." +# REMOVE SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index 5c74c1b..6407e7b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,33 +13,30 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." +ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the PHP-FPM configuration..." - -ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the MySQL database..." +ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE THE CRON FILE +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the cron file..." +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" @@ -50,7 +47,7 @@ chmod 644 "/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 4cb5a30..9e81856 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,7 @@ upgrade_type=$(ynh_check_app_version_changed) if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --keep=".env" @@ -31,31 +31,27 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# ADD A CRON JOB +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Adding a cron job..." - -ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low # Create a dedicated nginx config ynh_add_nginx_config + +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" + #================================================= # UPDATE A CONFIG FILE #================================================= if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Updating a configuration file..." + ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="default.env" --destination="$install_dir/.env" @@ -66,8 +62,7 @@ fi #================================================= # UPGRADE DATABASE #================================================= - -ynh_script_progression --message="Upgrading the database..." +ynh_script_progression --message="Upgrading the database..." --weight=1 pushd "$install_dir" # Clear caches