added RBL generate/expire scripts

This commit is contained in:
Oliver Ladner 2015-03-26 19:55:39 +01:00
commit 72eb89db56
2 changed files with 89 additions and 0 deletions

17
rbl_expire.sh Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# Expire old RBL records
maxage=48 # in hours
rblfile="/var/lib/rbldns/list"
egrep '^[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' $rblfile | while read -r ip delimiter timestamp foo; do
if [ "$timestamp" -gt "0" ]; then
expiration=$(echo "$(date +%s)-$timestamp" | bc)
if [ "$expiration" -gt "$(($maxage * 3600))" ]; then
#echo "entry $ip older than $maxage hours (expired $(($expiration / 3600)) hours ago)"
sed -i "/^$ip.*# $timestamp.*$/d" $rblfile || echo "Error while deleting $ip: $?"
fi
fi
done