From b0874022dfcefd578ad33205ca3bbdca3297f976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 12 Nov 2023 12:06:04 +0100 Subject: [PATCH] cleaning --- scripts/install | 53 ++++++++++--------------------------------------- scripts/remove | 27 ------------------------- scripts/restore | 26 +++++------------------- scripts/upgrade | 41 ++++++++++---------------------------- 4 files changed, 26 insertions(+), 121 deletions(-) diff --git a/scripts/install b/scripts/install index 3303033..676c152 100755 --- a/scripts/install +++ b/scripts/install @@ -39,13 +39,21 @@ ynh_script_progression --message="Compiling Fider application..." --weight=1 ynh_exec_warn_less build_fider #================================================= -# NGINX CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +# Create a dedicated systemd config +ynh_add_systemd_config + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate --nonappend + +yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" + #================================================= # SPECIFIC SETUP #================================================= @@ -60,39 +68,6 @@ ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" chown $app:www-data "$install_dir/run_fider" chmod 744 "$install_dir/run_fider" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. -### Use this helper only if there is effectively a log file for this app. -### If you're not using this helper: -### - Remove the section "BACKUP LOGROTATE" in the backup script -### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script -### - And the section "SETUP LOGROTATE" in the upgrade script - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate --nonappend - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= @@ -101,14 +76,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SETUP FAIL2BAN -#================================================= -# ynh_script_progression --message="Configuring Fail2Ban..." --weight=1 - -# Create a dedicated Fail2Ban config -# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 71c169b..ce48465 100755 --- a/scripts/remove +++ b/scripts/remove @@ -23,46 +23,19 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - ynh_remove_nodejs ynh_remove_go -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." --weight=1 - # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index d17ff90..a81d41a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -19,15 +19,7 @@ ynh_restore_file --origin_path="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" - -chmod +x "$install_dir/run_fider" - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +chmod 744 "$install_dir/run_fider" #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -37,28 +29,20 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --weight ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - mkdir -p "/var/log/$app/" touch "/var/log/$app/$app.log" chown -R $app:$app "/var/log/$app/" ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 633c4c0..edbabba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,50 +56,31 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC UPGRADE +# Create a dedicated systemd config +ynh_add_systemd_config + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" + #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating the configuration file..." --weight=1 +ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="run_fider" --destination="$install_dir/run_fider" chown $app:www-data "$install_dir/run_fider" chmod 744 "$install_dir/run_fider" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Fider Feedback platform" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #=================================================