Skip to content
Snippets Groups Projects
Verified Commit f6d53c23 authored by David Beniamine's avatar David Beniamine
Browse files

Update unban.sh with new fail2ban commands

parent bc4f2f53
No related branches found
No related tags found
No related merge requests found
......@@ -8,23 +8,13 @@ then
exit 1
fi
ip=$1
nojail=true
# Trying to remove from all jails
for jail in $(fail2ban-client status | grep 'Jail list' | \
sed -e 's/.*list:\s*//' -e 's/,//g')
do
echo "Looking for $ip in jail $jail"
fail2ban-client set $jail unbanip $ip > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "ip removed from jail $jail"
nojail=false
fi
done
if $nojail
then
echo "$ip wasn't in any jail"
fail2ban-client unban $ip
if [ $? -eq 1 ]; then
echo "$ip unbanned"
else
echo "$ip was not banned"
fi
# To avoid mail report
sed -i "/Ban $ip/d" /var/log/fail2ban.log
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment