aboutsummaryrefslogtreecommitdiff
path: root/mail/exim/files/150.exim-tidydb.sh
blob: 34a25236b6d81634319f0e0022823f0cd2aa695d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
#
# Exim hints database maintenance
# 
#   contributed by: Oliver Eikemeier <eikemeier@fillmore-labs.com>
#

# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]; then
    . /etc/defaults/periodic.conf
    source_periodic_confs
fi

: ${exim_tidydb_enable="YES"}
: ${exim_tidydb="%%PREFIX%%/sbin/exim_tidydb"}
# Set this to arbitrary shell command to filter
# the output from this periodic script, for example,
# exim_tidydb_filter="| tail -100".
: ${exim_tidydb_filter=""}
: ${exim_dbdir="/var/spool/exim"}

tidy () {
	for db in "$exim_dbdir"/db/*.lockfile; do
	    [ "$db" = "$exim_dbdir/db/*.lockfile" ] && continue
	    echo
	    db_name=`basename "$db" .lockfile`
	    if [ -e "${exim_dbdir}/db/${db_name}" ]; then
	        "$exim_tidydb" "$exim_dbdir" "$db_name"
	    fi
	done
}

case "$exim_tidydb_enable" in
    [Yy][Ee][Ss])
	echo ""
	echo "Tidying Exim hints databases:"
	eval tidy "$exim_tidydb_filter"
	if [ $? = 0 ]; then
		rc=0
	else
		rc=1
	fi
	;;

    *)  rc=0;;
esac

exit $rc