mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Simplify fail2ban output (#2703)
This commit is contained in:
parent
57aeb6db2a
commit
11f8cc7ee9
|
@ -9,7 +9,6 @@ fail2ban-client ping &>/dev/null || _exit_with_error "Fail2ban not running"
|
||||||
|
|
||||||
unset JAILS
|
unset JAILS
|
||||||
declare -a JAILS
|
declare -a JAILS
|
||||||
IP_REGEXP='((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
|
||||||
|
|
||||||
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g')
|
for LIST in $(fail2ban-client status | grep "Jail list" | cut -f2- | sed 's/,/ /g')
|
||||||
do
|
do
|
||||||
|
@ -22,13 +21,11 @@ then
|
||||||
|
|
||||||
for JAIL in "${JAILS[@]}"
|
for JAIL in "${JAILS[@]}"
|
||||||
do
|
do
|
||||||
BANNED_IPS=$(fail2ban-client status "${JAIL}" \
|
BANNED_IPS=$(fail2ban-client status "${JAIL}" | grep -oP '(?<=Banned IP list:\s).+')
|
||||||
| grep 'Banned IP list' \
|
|
||||||
| grep -oE "${IP_REGEXP}")
|
|
||||||
|
|
||||||
if [[ -n ${BANNED_IPS} ]]
|
if [[ -n ${BANNED_IPS} ]]
|
||||||
then
|
then
|
||||||
echo "Banned in ${JAIL}: ${BANNED_IPS//$'\n'/, }"
|
echo "Banned in ${JAIL}: ${BANNED_IPS}"
|
||||||
IPS_BANNED=1
|
IPS_BANNED=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue