From 4a7390447f1fef8894d050873140af0c815b2479 Mon Sep 17 00:00:00 2001 From: lapineige Date: Mon, 22 Jul 2019 16:27:12 +0200 Subject: [PATCH] Fail2ban fixes (#44) * fix fail2ban * fix fail2ban --- scripts/_common.sh | 4 ++-- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b8f4a48..b6e361d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,7 +31,7 @@ pkg_dependencies="php-cli php-gettext php-curl php-intl php-gd php-mbstring open # | arg: failregex - Failregex to be looked for by fail2ban # | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3 # | arg: ports - Ports blocked for a banned IP address - default: http,https -ynh_add_fail2ban_config () { +ynh_add_fail2ban_config_temp () { # Process parameters logpath=$1 failregex=$2 @@ -66,7 +66,7 @@ EOF ynh_store_file_checksum "$finalfail2banjailconf" ynh_store_file_checksum "$finalfail2banfilterconf" - systemctl restart fail2ban + service fail2ban restart local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")" if [ -n "$fail2ban_error" ] then diff --git a/scripts/install b/scripts/install index ae08cce..2e4922e 100644 --- a/scripts/install +++ b/scripts/install @@ -159,7 +159,7 @@ ynh_use_logrotate "$final_path/data/log.txt" # SETUP FAIL2BAN #================================================= ynh_print_info "Add Fail2Ban configuration..." -ynh_add_fail2ban_config "$final_path/data/log.txt" "\s-\s\s-\sLogin failed for user.*$" 5 +ynh_add_fail2ban_config_temp "$final_path/data/log.txt" "\s-\s\s-\sLogin failed for user.*$" 5 #================================================= # SETUP SSOWAT diff --git a/scripts/upgrade b/scripts/upgrade index ea3ac60..3a42927 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -135,7 +135,7 @@ ynh_use_logrotate --non-append # SETUP FAIL2BAN #================================================= ynh_print_info "Upgrading Fail2Ban configuration..." -ynh_add_fail2ban_config "$final_path/data/log.txt" "\s-\s\s-\sLogin failed for user.*$" 5 +ynh_add_fail2ban_config_temp "$final_path/data/log.txt" "\s-\s\s-\sLogin failed for user.*$" 5 # Set right permissions chown -R $app: $final_path