~ubuntu-branches/ubuntu/karmic/cyrus-imapd-2.2/karmic

« back to all changes in this revision

Viewing changes to debian/cyrus-common-2.2.cyrus2.2.init

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-12-07 17:31:51 UTC
  • Revision ID: james.westby@ubuntu.com-20061207173151-u34z5dafs5nh9sat
Tags: 2.2.13-9ubuntu1
* Merge with Debian unstable; remaining changes:
  - Build using DB4.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#               Various modifications done by Sven Mueller <debian@incase.de>
21
21
#               Distributed under the GPL version 2
22
22
#
23
 
# $Id: cyrus-common-2.2.cyrus2.2.init 488 2006-06-18 21:00:34Z sven $
 
23
# $Id: cyrus-common-2.2.cyrus2.2.init 681 2006-10-25 17:42:18Z astronut $
24
24
 
25
25
# Make sure we get sane results on borked locales
26
26
LC_ALL=C
29
29
# Overridable defaults
30
30
unset CYRUS_VERBOSE
31
31
unset LISTENQUEUE
 
32
unset CONF
 
33
unset MASTERCONF
32
34
[ -r /etc/default/cyrus2.2 ] && . /etc/default/cyrus2.2
33
35
 
34
36
[ "x${CYRUS_VERBOSE}" != "x" ] && export CYRUS_VERBOSE
35
 
OPTIONS="-d"
 
37
# Make sure the master process is daemonized
 
38
OPTIONS="${OPTIONS} -d"
 
39
[ "x${CONF}" != "x" ] && OPTIONS="-C ${CONF} ${OPTIONS}"
 
40
[ "x${MASTERCONF}" != "x" ] && OPTIONS="-M ${MASTERCONF} ${OPTIONS}"
36
41
[ "x${LISTENQUEUE}" != "x" ] && OPTIONS="-l ${LISTENQUEUE} ${OPTIONS}"
37
42
 
38
43
PATH=/sbin:/usr/sbin:/bin:/usr/bin
39
44
DAEMON=/usr/sbin/cyrmaster
40
45
NAME=cyrmaster
 
46
[ "x${PIDFILE}" = "x" ] && PIDFILE="/var/run/${NAME}.pid"
41
47
DESC="Cyrus IMAPd"
42
48
 
 
49
#�Check if Cyrus 2.2 is installed
43
50
test -x ${DAEMON} || exit 0
 
51
grep -qE '^PACKAGE_VERSION[[:blank:]]+2[.]2' \
 
52
        /usr/lib/cyrus/cyrus-hardwired-config.txt >/dev/null 2>&1 || exit 0
44
53
 
45
54
set -e
46
55
 
47
 
START="--start --quiet --pidfile /var/run/${NAME}.pid --exec ${DAEMON} --name ${NAME} -- ${OPTIONS}"
 
56
START="--start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} --name ${NAME} -- ${OPTIONS}"
48
57
 
49
58
verifydb() {
50
59
   while read -r DBKEY DBVALUE ; do
86
95
        else
87
96
                PRINTIT=true 
88
97
        fi
89
 
        if [ ! -f /var/run/${NAME}.pid ]; then
 
98
        if [ ! -f ${PIDFILE} ]; then
90
99
                # using [c] in the grep avoids catching the grep 
91
100
                # process itself
92
101
                if ps auxww | grep -qE 'usr/sbin/[c]yrmaster' ; then
94
103
                        # exists. Though strictly speaking, we should not
95
104
                        # do this, reconstruct the PID file here.
96
105
                        pidof /usr/sbin/cyrmaster > /dev/null 2>&1 \
97
 
                        && pidof /usr/sbin/cyrmaster > /var/run/${NAME}.pid
98
 
                        ${PRINTIT} "cyrmaster running with PID `cat /var/run/${NAME}.pid`"
 
106
                        && pidof /usr/sbin/cyrmaster > ${PIDFILE}
 
107
                        ${PRINTIT} "cyrmaster running with PID `cat ${PIDFILE}`"
99
108
                        return 0
100
109
                fi
101
110
        fi      
102
 
        if [ -s /var/run/${NAME}.pid ] && kill -0 `cat /var/run/${NAME}.pid` > /dev/null 2>&1; then
103
 
                ${PRINTIT} "cyrmaster running with PID `cat /var/run/${NAME}.pid`"
 
111
        if [ -s ${PIDFILE} ] && kill -0 `cat ${PIDFILE}` > /dev/null 2>&1; then
 
112
                ${PRINTIT} "cyrmaster running with PID `cat ${PIDFILE}`"
104
113
                return 0
105
114
        else
106
115
                # the PID file might simply not match the cyrmaster process.
107
116
                if pidof /usr/sbin/cyrmaster > /dev/null 2>&1 ; then
108
117
                        # go ahead and fix it
109
 
                        pidof /usr/sbin/cyrmaster > /var/run/${NAME}.pid
110
 
                        ${PRINTIT} "cyrmaster running with PID `cat /var/run/${NAME}.pid`"
 
118
                        pidof /usr/sbin/cyrmaster > ${PIDFILE}
 
119
                        ${PRINTIT} "cyrmaster running with PID `cat ${PIDFILE}`"
111
120
                        return 0
112
121
                else
113
122
                        # no process and/or no PID file, return failure
159
168
        if start-stop-daemon ${START} >/dev/null 2>&1 ; then
160
169
                echo "$NAME."
161
170
        else
162
 
                if !check_status ; then
 
171
                if ! check_status ; then
163
172
                        echo "(failed)."
164
173
                        exit 1
165
174
                fi
170
179
        if start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
171
180
                --name ${NAME} --quiet --startas $DAEMON >/dev/null 2>&1 ; then
172
181
                echo "$NAME."
173
 
                rm -f /var/run/${NAME}.pid
 
182
                rm -f ${PIDFILE}
174
183
                exit 0
175
184
        else
176
185
                # process running?
182
191
                        # No, return as if stopped a running process 
183
192
                        # successfully.
184
193
                        echo "."
185
 
                        rm -f /var/run/${NAME}.pid
 
194
                        rm -f ${PIDFILE}
186
195
                        exit 0
187
196
                fi
188
197
        fi