/[pkg-kolab]/trunk/kolab-cyrus-imapd/debian/kolab-cyrus-common.cron.daily
ViewVC logotype

Contents of /trunk/kolab-cyrus-imapd/debian/kolab-cyrus-common.cron.daily

Parent Directory Parent Directory | Revision Log Revision Log


Revision 333 - (show annotations) (download)
Mon Feb 20 21:22:38 2006 UTC (7 years, 3 months ago) by white-guest
File size: 2197 byte(s)
* moving the branch into trunk
1 #!/bin/sh
2 # Cyrus IMAPd daily maintenance script
3 # Copyright (c) 2002,2003 by Henrique M. Holschuh
4 # $Id: cyrus22-common.cron.daily 5 2005-03-12 23:19:45Z sven $
5 # Distributed under the terms of the GNU General Public License version 2
6 #
7 # This script:
8 # 1. Backups the mailbox database to the portable text format,
9 # and compresses the result. This backup can be used to restore
10 # the Cyrus mailbox database using ctl_mboxlist (after uncompressing
11 # the backup file).
12 #
13 # 2. Cleans up any leftover crap in .stage directories.
14 #
15 # 3. Runs chk_cyrus and outputs warning messages (so that cron
16 # sends them to the administrator) if any problems are detected.
17
18 set -e
19
20 # Make sure we get sane behaviour in broken locales
21 LC_ALL=C
22 export LC_ALL
23
24 bak=/var/backups
25 bakfile=${bak}/cyrus-mboxlist.txt.gz
26 CONF=/etc/imapd.conf
27 CHKCYRUS=0
28 [ -r /etc/default/kolab-cyrus ] && . /etc/default/kolab-cyrus
29 umask 022
30
31 # 1. backup mailbox database
32 [ -x /usr/sbin/ctl_mboxlist ] && {
33 [ -d $bak ] || ( mkdir -p $bak ; chmod 600 $bak )
34 [ -f $bakfile ] && mv ${bakfile} ${bakfile}.bak
35 # su "--command=/usr/sbin/ctl_mboxlist -d" - cyrus | ...
36 start-stop-daemon --start --exec /usr/sbin/ctl_mboxlist --quiet --chuid cyrus -- -d | gzip -9 >${bakfile}
37 }
38
39 # 2. clean up all leftover .stage directories in all spools listed in
40 # the default config file
41 [ $CHKCYRUS -ne 0 ] && {
42 [ -r "$CONF" ] || {
43 echo $0: unable to read configuration file $CONF. Aborting...
44 exit 1
45 }
46 partitions=$(sed --silent -e "/^[[:blank:]]*partition-[[:alnum:]]\+:/ { \
47 s#^[[:blank:]]*partition-[[:alnum:]]\+:[[:blank:]]*## \
48 p
49 } " < "$CONF" | sort | uniq | xargs)
50 for i in $partitions ; do
51 find "$i" -name '.stage' -type d -print0 | \
52 xargs --null -n 1 -r -i'{1}' \
53 find {1} -type f -ctime +1 -exec rm -f {} \;
54 done
55 }
56
57 # 3. runs chk_cyrus
58 [ -x /usr/sbin/chk_cyrus ] && {
59 tmpfile=$(mktemp -t cyrus-daily-cronjob.XXXXXXXXXX)
60 trap 'rm -f "${tmpfile}"' 0
61 # su "--command=/usr/sbin/chk_cyrus" - cyrus | ...
62 start-stop-daemon --start --exec /usr/sbin/chk_cyrus --quiet --chuid cyrus >"${tmpfile}" 2>&1 || cat "${tmpfile}" 1>&2
63 rm -f "${tmpfile}"
64 trap '' 0
65 }
66
67 exit 0

  ViewVC Help
Powered by ViewVC 1.1.5