#! /bin/sh -e
#
# cron script to clean up mailscanner files
#
# $Id: local-clock,v 1.5 2002/03/13 02:18:38 bcwhite Exp $
#
# Written by Brian White <bcwhite@precidia.com>
#

# how many days to keep quarantined messages
q_days=3

# load user-defaults
if [ -f /etc/default/mailscanner ]; then
    . /etc/default/mailscanner
fi

# go to mailscanner spool directory
cd /var/spool/MailScanner

# remove old files and directories
find quarantine -type f -ctime +$q_days    -exec rm -f {} \; >/dev/null 2>&1
find quarantine -type d -depth -mindepth 1 -exec rmdir {} \; >/dev/null 2>&1

# have exim update it's database (if we're using exim, that is)
if [ -x /usr/sbin/exim_tidydb -a -d /var/spool/exim_incoming ]; then
    /usr/sbin/exim_tidydb -t 0m /var/spool/exim_incoming retry >/dev/null
fi

# exit cleanly
exit 0
