mirror of
https://github.com/YunoHost-Apps/wordpress_ynh.git
synced 2024-09-03 20:36:10 +02:00
Update ynh_add_fail2ban_config helper
This commit is contained in:
parent
f819b23f04
commit
32571e25b7
1 changed files with 31 additions and 30 deletions
|
@ -83,7 +83,7 @@ enabled = true
|
||||||
port = $ports
|
port = $ports
|
||||||
filter = $app
|
filter = $app
|
||||||
logpath = $logpath
|
logpath = $logpath
|
||||||
maxretry = $max_retry"
|
maxretry = $max_retry
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sudo tee $finalfail2banfilterconf <<EOF
|
sudo tee $finalfail2banfilterconf <<EOF
|
||||||
|
@ -91,16 +91,17 @@ EOF
|
||||||
before = common.conf
|
before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
failregex = $failregex
|
failregex = $failregex
|
||||||
ignoreregrex ="
|
ignoreregex =
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ynh_store_file_checksum "$finalfail2banjailconf"
|
ynh_store_file_checksum "$finalfail2banjailconf"
|
||||||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||||
|
|
||||||
sudo systemctl restart fail2ban
|
systemctl restart fail2ban
|
||||||
if local fail2ban_error="$(tail -n50 /var/log/fail2ban.log | grep "WARNING Command.*$app.*addfailregex")"
|
local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")"
|
||||||
|
if [ -n "$fail2ban_error" ]
|
||||||
then
|
then
|
||||||
echo "[ERR] Fail2ban fail to load the jail for $app" >&2
|
echo "[ERR] Fail2ban failed to load the jail for $app" >&2
|
||||||
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue