%%(bash) #!/bin/sh # # Autoblock Cleanup 20060120 # /etc/autoblock/cleanup # Copyright 2006 by Jeff Taylor # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA BLOCKED=/etc/blocklist IPTABLES="/usr/sbin/iptables" ETH=eth0 ### Try to limit this to a single running copy if [ `ps ax | grep autoblock.clean | grep -v grep | wc -l` -gt 2 ]; then exit 0 ; fi while read LINE; do LINE=`echo $LINE | sed 's/[#]//g' | sed 's/^[ \t]*//'` IP=`echo $LINE | cut -d\ -f1` KillDATE=`echo $LINE | cut -d\ -f2-` if [ "$IP" ]; then bDATE=`date +%s -d "$KillDATE"` NOW=`date +%s` if [ $NOW -gt $bDATE ]; then $IPTABLES -D autoblock -i $ETH -s $IP -j autoblock_drop > /dev/null 2>&1 sed -e "/ $IP /d" $BLOCKED > $BLOCKED.x mv $BLOCKED.x $BLOCKED logger -t autoblock "Removed $IP from blocklist" fi fi done < $BLOCKED cat $BLOCKED | sort | uniq -w22 > $BLOCKED.x mv -f $BLOCKED.x $BLOCKED %% ---- CategoryDNSBlockList