1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/friendica_ynh.git synced 2024-09-03 18:36:14 +02:00

Merge pull request #107 from YunoHost-Apps/fail

add fail2ban
This commit is contained in:
eric_G 2023-08-21 12:26:55 +02:00 committed by GitHub
commit 979ad8a39e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 2 deletions

View file

@ -34,7 +34,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================

View file

@ -68,6 +68,18 @@ ynh_add_config --template="../conf/addon.config.php" --destination="$install_dir
mkdir -p "$install_dir/view/smarty3" mkdir -p "$install_dir/view/smarty3"
chmod -R 775 "$install_dir/view/smarty3" chmod -R 775 "$install_dir/view/smarty3"
#=================================================
# SETUP A CRON
#=================================================
ynh_script_progression --message="Setting up the cron job..." --weight=1
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
#================================================= #=================================================
# INSTALL FRIENDICA # INSTALL FRIENDICA
#================================================= #=================================================

View file

@ -32,7 +32,9 @@ ynh_remove_nginx_config
ynh_remove_fpm_config ynh_remove_fpm_config
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate #ynh_remove_logrotate
ynh_remove_fail2ban_config
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -42,6 +42,10 @@ systemctl enable $app.service --quiet
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log" yunohost service add $app --description="Friendica daemon" --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 # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -88,6 +88,9 @@ ynh_add_nginx_config
# Create a dedicated PHP-FPM config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low ynh_add_fpm_config --usage=low --footprint=low
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="^.*authenticate\: failed login attempt.*\"ip\"\:\"<HOST>\".*$"
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log" yunohost service add $app --description="Friendica daemon" --log="/var/log/$app/$app.log"