source: trunk/third/moira/gen/postoffice.sh @ 23740

Revision 23740, 2.3 KB checked in by broder, 16 years ago (diff)
In moira: * New CVS snapshot (Trac: #195) * Drop patches that have been incorporated upstream. * Update to build without krb4 on systems that no longer have it. This doesn't build yet on squeeze, which lacks a krb4 library, but I'm committing now before I start hacking away at a patch to fix that.
Line 
1#!/bin/sh
2# This script performs postoffice updates.
3#
4# $Header: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/gen/postoffice.sh,v 1.3 2000-05-08 18:30:30 zacheiss Exp $
5
6PATH=/sbin:/bin:/usr/sbin:/usr/bin:/etc:/usr/etc:/usr/athena/bin:/usr/local/bin
7export PATH
8
9if [ -d /var/athena ] && [ -w /var/athena ]; then
10    exec >/var/athena/moira_update.log 2>&1
11else
12    exec >/tmp/moira_update.log 2>&1
13fi
14
15# The following exit codes are defined and MUST BE CONSISTENT with the
16# error codes the library uses:
17MR_NOCRED=47836470
18MR_MISSINGFILE=47836473
19MR_MKCRED=47836474
20MR_TARERR=47836476
21
22umask 22
23
24TARFILE=/var/tmp/po.out
25SRC_DIR=/var/tmp/po.dir
26IMAP_ROOT=/usr/local/cyrus
27IMAP_CONFIG=${IMAP_ROOT}/config
28IMAP_CHECK=${IMAP_CONFIG}/ignore_update_checks
29IMAP_MBOXES=${IMAP_CONFIG}/mailboxes.input;
30IMAP_QUOTA=${IMAP_CONFIG}/quota
31IMAP_QINPUT=${IMAP_QUOTA}/input
32IMAP_BIN=${IMAP_ROOT}/bin
33
34
35#
36# handle tar file
37#
38
39if [ ! -r ${TARFILE} ]; then
40        exit ${MR_TARERR}
41fi
42
43rm -rf ${SRC_DIR}
44mkdir ${SRC_DIR}
45chmod 700 ${SRC_DIR}
46
47uchost=`hostname | tr '[a-z]' '[A-Z]'`
48echo $uchost | egrep -e "\." > /dev/null
49if [ $? != 0 ]; then
50        domain=`grep domain /etc/resolv.conf | awk '{print $2}' |tr '[a-z]' '[A-Z]'`
51
52        uchost=$uchost.$domain
53fi
54
55cd ${SRC_DIR}
56tar xvf ${TARFILE}
57if [ $? != 0 ]; then
58        exit ${MR_TARERR}
59fi
60
61if [ ! -d $uchost ]; then
62        echo "no directory for "$uchost
63        exit ${MR_MISSINGFILE}
64fi
65
66cd $uchost
67
68
69#
70# handle mboxes file
71#
72
73cp mailboxes ${IMAP_MBOXES}
74if [ $? != 0 ]; then
75        echo "failed to copy mailboxes"
76        exit ${MR_NOCRED}
77fi
78
79if [ -r {$IMAP_MBOXES} ]; then
80        egrep "\..*\." ${IMAP_CONFIG}/mailboxes >> ${IMAP_MBOXES}
81fi
82
83sort -o ${IMAP_MBOXES} ${IMAP_MBOXES}
84
85
86#
87# handle quotas
88#
89
90rm -f ${IMAP_QINPUT}
91cp quota ${IMAP_QINPUT}
92if [ $? != 0 ]; then
93        echo "failed to copy quota"
94        exit ${MR_NOCRED}
95fi
96
97
98#
99# save
100#
101cp ${IMAP_CONFIG}/mailboxes ${IMAP_CONFIG}/mailboxes.save
102
103#
104# synchronize
105#
106LD_LIBRARY_PATH=/usr/local/tcl/lib
107export LD_LIBRARY_PATH
108
109${IMAP_BIN}/cyradm -file ${IMAP_BIN}/sync.cyradm sync -d
110if [ $? != 0 ]; then
111        exit ${MR_MKCRED}
112fi
113
114#
115# backup
116#
117cp ${IMAP_CONFIG}/mailboxes ${IMAP_CONFIG}/mailboxes.backup
118
119#
120# cleanup
121#
122
123if [ -f ${TARFILE} ]; then
124         rm -f ${TARFILE}
125fi
126
127if [ -d ${SRC_DIR} ]; then
128        cd ${SRC_DIR}/..
129        rm -rf ${SRC_DIR}
130fi
131
132if [ -f $0 ]; then
133         rm -f $0
134fi
135
136exit 0
Note: See TracBrowser for help on using the repository browser.