From a6707aa7d46ae19b58bc0a3fda48256260d2703f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 12 May 2024 17:39:01 +0200 Subject: [PATCH] cleaning --- scripts/backup | 26 +------------------------- scripts/change_url | 2 +- scripts/install | 4 ++-- scripts/remove | 33 --------------------------------- scripts/restore | 32 -------------------------------- scripts/upgrade | 20 +++++--------------- 6 files changed, 9 insertions(+), 108 deletions(-) diff --git a/scripts/backup b/scripts/backup index 9afc156..39612b8 100755 --- a/scripts/backup +++ b/scripts/backup @@ -22,42 +22,18 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="$install_dir" #================================================= -# BACKUP THE NGINX CONFIGURATION +# SYSTEM 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 LOGS -#================================================= - -ynh_backup --src_path="/var/log/nginx/$domain-access.log" - -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= - ynh_backup --src_path="/etc/logrotate.d/$app" -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= - ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.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 ac1d4f7..3952683 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,7 +23,7 @@ ynh_change_url_nginx_config #================================================= # UPGRADING FRESHRSS #================================================= -ynh_script_progression --message="Upgrading FreshRSS..." --weight=1 +ynh_script_progression --message="Upgrading $app..." --weight=1 ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/cli/reconfigure.php" --auth_type http_auth --environment production --base_url "https://$new_domain$new_path" --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user "$db_name" --db-password "$db_pwd" --db-base "$db_name" diff --git a/scripts/install b/scripts/install index 52cd34e..47d6845 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,7 @@ ynh_add_fpm_config # Create a dedicated NGINX config ynh_add_nginx_config -ynh_add_config --template="../conf/freshrss.cron" --destination="/etc/cron.d/$app" +ynh_add_config --template="freshrss.cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" @@ -65,7 +65,7 @@ ynh_add_fail2ban_config --logpath="/var/log/${domain}-access.log" --failregex="< #================================================= # SETUPING FRESHRSS #================================================= -ynh_script_progression --message="FreshRSS setup..." --weight=1 +ynh_script_progression --message="$app setup..." --weight=1 ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/cli/do-install.php" --default_user "$admin" --auth_type http_auth --environment production --base_url "https://$domain$path" --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user "$db_name" --db-password "$db_pwd" --db-base "$db_name" diff --git a/scripts/remove b/scripts/remove index 3ff5c07..c8cafdf 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,56 +12,23 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SYSTEMD SERVICE -#================================================= ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP configuration..." --weight=1 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE CRON CONFIGURATION -#================================================= -ynh_script_progression --message="Removing Cron configuration..." --weight=1 - # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" -#================================================= -# REMOVE LOG FILES -#================================================= -ynh_script_progression --message="Removing log files..." --weight=1 - # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE FAIL2BAN CONFIGURATION -#================================================= - -ynh_script_progression --message="Removing fail2ban configuration..." --weight=1 - ynh_remove_fail2ban_config #================================================= diff --git a/scripts/restore b/scripts/restore index 7df2611..f39723b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,48 +30,16 @@ ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name #================================================= # RESTORE SYSTEM CONFIGURATIONS #================================================= -# 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" -#================================================= -# RESTORE LOGS -#================================================= -ynh_script_progression --message="Restoring the log files..." --weight=1 - -ynh_restore_file --origin_path="/var/log/nginx/$domain-access.log" - -log_path="/var/log/$app" -mkdir -p "$log_path" -chown "$app":www-data "$log_path" - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE CRON CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the Cron configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/cron.d/$app" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# RESTORE THE FAIL2BAN CONFIGURATION -#================================================= - ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" ynh_systemd_action --action=restart --service_name=fail2ban diff --git a/scripts/upgrade b/scripts/upgrade index 28b8b95..85fac19 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -47,23 +47,13 @@ chmod -R o-rwx "$install_dir" chown -R "$app":www-data "$install_dir" #================================================= -# REAPPLY SYSTEM CONFIGURATIONS +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 - -#================================================= -# PHP CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP configuration..." +ynh_script_progression --message="Updating $app's configuration files..." --weight=1 # Create a dedicated PHP-FPM config ynh_add_fpm_config -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config @@ -72,7 +62,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading Cron configuration..." -ynh_add_config --template="../conf/freshrss.cron" --destination="/etc/cron.d/$app" +ynh_add_config --template="freshrss.cron" --destination="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" @@ -103,7 +93,7 @@ ynh_use_logrotate --non-append #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Upgrading fail2ban configuration..." +ynh_script_progression --message="Upgrading Fail2Ban configuration..." # If it doesn't exist, create the logfile, required before configuring fail2ban if [ ! -f "/var/log/${domain}-access.log" ]; then @@ -118,7 +108,7 @@ ynh_add_fail2ban_config --logpath="/var/log/${domain}-access.log" --failregex="< #================================================= # UPGRADING FRESHRSS #================================================= -ynh_script_progression --message="Upgrading FreshRSS..." --weight=1 +ynh_script_progression --message="Upgrading $app..." --weight=1 # reconfigure application with latest parameters ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/cli/reconfigure.php" --default_user "$admin" --auth_type http_auth --environment production --base_url "https://$domain$path" --title FreshRSS --api_enabled --db-type mysql --db-host localhost --db-user "$db_name" --db-password "$db_pwd" --db-base "$db_name"