Hi all!

I created a bash-script to analyze and clean up my greylist. Maybe someone needs one which
reports what has been done or just check the greylist without deleting.

I use this one, because a simple find over 90 Domains and 2k Mailaccounts caused high server load, this step-by-step processing didn't - if there's not a million entries in one
domain. ;-)

Greetz,

Blackbit
#!/bin/bash

#
# What's this:
# This script was created to keep the greylist of spamdyke
# up 2 date and remove old entries. On a server with 1k mailboxes
# it works fine and is in productive use.
#
# Note:
# As this script is removing files whithout any possibility to
# undo these deletions, we recommend to try out the script
# with set debug-flag below to see what will be purged.
#

#Location of your greylist
greylist=/var/qmail/spamdyke/greylist

#Number of days to keep greylist
daystodel=28

#Set this this to 1 to see the results without removing any file
debug=0

#Report summary in the end
report=1

#Everything is set up now, let it run!
#nothing needs to be modified below this line (i hope)

minstodel=$[$daystodel*1440]
for domain in `ls -1 $greylist`
do
        if [ -d $greylist/$domain/. ];
        then
                greylisted=`find $greylist/$domain -type f | wc -l`
                greysum=$[$greysum+$greylisted]

                if [ $debug -eq 0 ]; then
                        find $greylist/$domain/ -mmin +$minstodel -size 0k 
-exec rm {} \;
                else
                        find $greylist/$domain/ -mmin +$minstodel -size 0k 
-exec ls -l {} \;
                fi
                deleted=`find $greylist/$domain -type f | wc -l`

                deleted=$[$greylisted-$deleted]
                if [ $debug -gt 0 ]; then
                        if [ $deleted -gt 0 ]; then
                                echo Domain: $domain $greylisted entries, 
$[$greylisted-$deleted] entries removed;
                        else
                                echo "Domain: $domain, $greylisted entries"
                        fi
                fi
                purged=$[$purged+$deleted]
        fi

done

if [ $report -gt 0 ]; then
        echo $greysum entries found
        echo $purged entries removed
        echo $[$greysum-$purged] entries remain greylisted
fi
_______________________________________________
spamdyke-users mailing list
[email protected]
http://www.spamdyke.org/mailman/listinfo/spamdyke-users

Reply via email to