#! /bin/sh for ip in echo `grep Ban /var/log/fail2ban.log | awk '{print $NF}' | sort | uniq` do for email in `whois $ip | perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' | sort | uniq` do echo "Sending email to $email ..." echo "Hi, The IP $ip has just been banned. Here are more information about $ip: `whois $ip` Regards," | mail -s "$ip banned" $email; done done
dpkg -l |awk '/^rc/ {print $2}' | xargs sudo dpkg --purge