wok view cyrus-imapd/stuff/etc/init.d/cyrus-imapd @ rev 2350

Cyrus-imapd: set passwd for cyrus user
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 04 16:34:19 2009 +0000 (2009-03-04)
parents 992291a415ab
children bc316434f97b
line source
1 #!/bin/sh
2 # /etc/init.d/cyrus-imapd : Start, stop and restart IMAP server on SliTaz, at
3 # boot time or with the command line.
4 #
5 # To start IMAP server at boot time, just put cyrus-imapd in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=cyrus-imapd
12 DESC="IMAP server"
13 DAEMON=/usr/cyrus/bin/master
14 OPTIONS=$CYRUS_OPTIONS
15 PIDFILE=/var/run/cyrus.master.pid
16 [ -n "$OPTIONS" ] || OPTIONS="-d -p $PIDFILE"
18 case "$1" in
19 start)
20 if active_pidfile $PIDFILE master ; then
21 echo "$NAME already running."
22 exit 1
23 fi
24 dir=$(grep ^configdirectory /etc/imapd.conf | awk '{ print $2 }')
25 if [ -f $dir/mailboxes.db ]; then
26 echo -n "Initialize $DESC: "
27 /usr/cyrus/bin/mkimap
28 for i in user quota ; do
29 for j in a b c d e f g h i j k l m n o p q r s t u v w x y z ; do
30 [ -d $dir/$i/$j ] || mkdir -p $dir/$i/$j
31 done
32 done
33 chown -R cyrus:mail $dir
34 chmod 750 $dir
35 su cyrus -c "/usr/cyrus/bin/ctl_cyrusdb -r"
36 su cyrus -c "/usr/cyrus/bin/reconstruct"
37 status
38 fi
39 if ! pidof saslauthd > /dev/null; then
40 /etc/init.d/cyrus-sasl start
41 fi
42 echo -n "Starting $DESC: $NAME... "
43 $DAEMON $OPTIONS
44 status
45 sleep 2
46 ;;
47 stop)
48 if ! active_pidfile $PIDFILE master ; then
49 echo "$NAME is not running."
50 exit 1
51 fi
52 echo -n "Stopping $DESC: $NAME... "
53 kill `cat $PIDFILE`
54 ps x | grep -q `cat $PIDFILE` || rm -f $PIDFILE
55 status
56 ;;
57 restart)
58 if ! active_pidfile $PIDFILE master ; then
59 echo "$NAME is not running."
60 exit 1
61 fi
62 echo -n "Restarting $DESC: $NAME... "
63 kill `cat $PIDFILE`
64 if ps x | grep -q `cat $PIDFILE`; then
65 false
66 else
67 rm -f $PIDFILE
68 sleep 2
69 $DAEMON $OPTIONS
70 fi
71 status
72 ;;
73 *)
74 echo ""
75 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
76 echo ""
77 exit 1
78 ;;
79 esac
81 exit 0