From 8841e1c0f7dfc4bf4fa4f478dbe093022e1000fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:47:23 +0100 Subject: [PATCH] fix --- scripts/backup | 15 +++++++++++++++ scripts/install | 6 ++++++ scripts/remove | 4 ++++ scripts/restore | 6 ++++++ scripts/upgrade | 6 ++++++ 5 files changed, 37 insertions(+) diff --git a/scripts/backup b/scripts/backup index 59c90ce..9ba4b32 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,6 +27,21 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# BACKUP FAIL2BAN CONFIGURATION +#================================================= + +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= + +ynh_backup --src_path="/etc/logrotate.d/$app" + #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index dcf3dbd..535805b 100755 --- a/scripts/install +++ b/scripts/install @@ -48,6 +48,12 @@ ynh_add_systemd_config yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: \)$" + #================================================= # APP INITIAL CONFIGURATION #================================================= diff --git a/scripts/remove b/scripts/remove index 9acfbb5..fb0a78d 100755 --- a/scripts/remove +++ b/scripts/remove @@ -31,6 +31,10 @@ ynh_remove_nginx_config ynh_remove_nodejs +ynh_remove_logrotate + +ynh_remove_fail2ban_config + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 2cd7ed6..52af54b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -48,6 +48,12 @@ systemctl enable $app.service --quiet yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log" +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +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 + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 23c720b..afbcf17 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -47,6 +47,12 @@ ynh_add_systemd_config yunohost service add $app --description="Realtime kanban board for workgroups" --log="/var/log/$app/$app.log" +# Use logrotate to manage application logfile(s) +ynh_use_logrotate --non-append + +# Create a dedicated Fail2Ban config +ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^(.*) Invalid (email or username:|password!) (\"(.*)\"!)? ?\(IP: \)$" + #================================================= # RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) #=================================================