#!/bin/sh
#
# nightly Exim maintenance
# clean databases and check for problems
#
# $Cambridge: hermes/conf/exim/sbin/nightly,v 1.14 2010/06/21 11:32:09 fanf2 Exp $

PATH=/bin:/usr/bin:/opt/exim/bin

my_exim_tidydb () {
	if [ -f $1/db/$2 ]; then
		exim_tidydb $1 $2
	fi
}

(
	my_exim_tidydb /var/spool/exim callout
	my_exim_tidydb /var/spool/exim ratelimit
	my_exim_tidydb /var/spool/exim retry
	my_exim_tidydb /var/spool/exim wait-smtp
	my_exim_tidydb /var/spool/exim wait-hermes_lmtp
) |
	egrep -v '^Tidying|deleted|updated|renamed'

# this file is populated by exicheck
if [ -s /spool/exim/frozen ]
then
	echo "***"
	echo "***" `hostname` frozen messages
	echo "***"
	echo "count / sender"
	cat /spool/exim/frozen
	echo
fi

exit 0
