1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ntfy_ynh.git synced 2024-09-03 19:46:27 +02:00

fail2ban support

This commit is contained in:
OniriCorpe 2024-01-16 20:47:43 +01:00
parent bb8f3627f4
commit 3151cab57e
5 changed files with 18 additions and 4 deletions

View file

@ -21,11 +21,15 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
# BACKUP SYSTEM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
# Backup the Fail2Ban config
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# BACKUP SYSTEMD
#=================================================

View file

@ -46,6 +46,9 @@ ynh_add_systemd_config
yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log"
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="limiting requests, excess:.* by zone.*client: <HOST>"
#=================================================
# ADD A CONFIGURATION
#=================================================

View file

@ -21,6 +21,8 @@ ynh_remove_systemd_config
ynh_remove_nginx_config
ynh_remove_fail2ban_config
#=================================================
# END OF SCRIPT
#=================================================

View file

@ -22,8 +22,6 @@ chown -R "$app:www-data" "$install_dir"
#=================================================
# 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/nginx/conf.d/$domain.d/$app.conf"
@ -33,10 +31,14 @@ systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Open Source Push Notification Server" --log="/var/log/$app/$app.log"
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
#=================================================
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
# RELOAD NGINX AND THE APP SERVICE
#=================================================
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1

View file

@ -59,6 +59,9 @@ ynh_script_progression --message="Updating a configuration file..." --weight=1
ynh_add_config --template="server.yml" --destination="$install_dir/server.yml"
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="limiting requests, excess:.* by zone.*client: <HOST>"
#=================================================
# ADD A CONFIGURATION
#=================================================