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

cyrus-imapd: fix paths
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 03 17:48:04 2010 +0100 (2010-03-03)
parents 54134b594899
children 7f188676b59c
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/lib/cyrus/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 db proc socket log msg user quota; do
29 [ -d $dir/$i ] || mkdir -p -m 700 $dir/$i
30 done
31 for i in user quota ; do
32 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
33 [ -d $dir/$i/$j ] || mkdir -p $dir/$i/$j
34 done
35 done
36 chown -R cyrus:mail $dir
37 chmod 750 $dir $dir/socket
38 for i in $(grep ^partition /etc/imapd.conf | awk '{ print $2 }') ; do
39 [ -d $i ] || mkdir -p -m 750 $i
40 case "$(grep ^hashimapspool /etc/imapd.conf | awk '{ print $2 }')" in
41 y*|t*|1|on)
42 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
43 [ -d $i/$j ] || mkdir -p $i/$j
44 done ;;
45 esac
46 [ -d $i/stage. ] || mkdir $i/stage.
47 chown -R cyrus:mail $i
48 done
49 case "$(grep ^sieveusehomedir /etc/imapd.conf | awk '{ print $2 }')" in
50 y*|t*|1|on)
51 sieve=$(grep ^sievedir /etc/sieve | awk '{ print $2 }')
52 [ -d $sieve ] || mkdir $sieve
53 chmod 755 $sieve
54 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
55 [ -d $sieve/$j ] || mkdir -p -m 755 $sieve/$j
56 done
57 chown -R cyrus:mail $sieve ;;
58 esac
59 su cyrus -c "/usr/cyrus/bin/ctl_cyrusdb -r"
60 su cyrus -c "/usr/cyrus/bin/reconstruct"
61 status
62 fi
63 if ! pidof saslauthd > /dev/null; then
64 /etc/init.d/cyrus-sasl start
65 fi
66 echo -n "Starting $DESC: $NAME... "
67 $DAEMON $OPTIONS
68 status
69 sleep 2
70 ;;
71 stop)
72 if ! active_pidfile $PIDFILE master ; then
73 echo "$NAME is not running."
74 exit 1
75 fi
76 echo -n "Stopping $DESC: $NAME... "
77 kill `cat $PIDFILE`
78 ps x | grep -q `cat $PIDFILE` || rm -f $PIDFILE
79 status
80 ;;
81 restart)
82 if ! active_pidfile $PIDFILE master ; then
83 echo "$NAME is not running."
84 exit 1
85 fi
86 echo -n "Restarting $DESC: $NAME... "
87 kill `cat $PIDFILE`
88 if ps x | grep -q `cat $PIDFILE`; then
89 false
90 else
91 rm -f $PIDFILE
92 sleep 2
93 $DAEMON $OPTIONS
94 fi
95 status
96 ;;
97 *)
98 echo ""
99 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
100 echo ""
101 exit 1
102 ;;
103 esac
105 exit 0