Add Fail2ban support to check. Restart fail2ban if the f2b chains are not active in firewall

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4200 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-05-02 12:11:27 +00:00
parent 3fad12515a
commit 2c4b7428c6
2 changed files with 18 additions and 1 deletions

14
check
View File

@@ -328,6 +328,20 @@ function testFichierPresent
fi
}
function testFail2BanActive
{
## Cette fonction verifie si des chaines f2b- existent bien dans iptables
## Si ce n'est pas le cas, essaie de redémarrer fail2ban
if [ ! -e "/etc/init.d/fail2ban" ]; then
checklog "ERREUR : /etc/init.d/fail2ban introuvable"
else
/sbin/iptables -L -nv |egrep -q "^Chain f(ail)?2b(an)?-" || (
checklog "ERREUR : fail2ban absent dans iptables : redémarrage";
/etc/init.d/fail2ban stop ;
/etc/init.d/fail2ban start )
fi
}
if [ ! -f "/etc/check.conf" ]; then
echo "Le fichier /etc/check.conf n'existe pas : EXIT"
exit

View File

@@ -76,3 +76,6 @@ alerteNotify=FALSE
# Si ce n'est pas le cas, relance le programme passé en deuxième paramètre
# testFichierPresent /var/run/conntrackd.ctl conntrackd
# Cette fonction vérifie si les chaines f2b- ou fail2ban- sont bien actives
# dans iptables. Relance le service fail2ban si ce n'est pas le cas
#testFail2BanActive