]> git.pld-linux.org Git - packages/cyrus-imapd.git/blob - cyrus-imapd.init
- add try-restart
[packages/cyrus-imapd.git] / cyrus-imapd.init
1 #!/bin/sh
2 #
3 # cyrus-imapd   cyrus-imapd IMAP & POP3 Server
4 #
5 # chkconfig:    345 85 15
6 #
7 # description:  cyrus-imapd
8
9 # Source function library
10 . /etc/rc.d/init.d/functions
11
12 # Get network config
13 . /etc/sysconfig/network
14
15 # Check that networking is up.
16 if is_yes "${NETWORKING}"; then
17         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
18                 msg_network_down cyrus-imapd
19                 exit 1
20         fi
21 else
22         exit 0
23 fi
24
25 start() {
26         # Check if the service is already running?
27         if [ ! -f /var/lock/subsys/cyrus-imapd ]; then
28                 msg_starting cyrus-imapd
29                 /usr/lib/cyrus/cyrus-master &
30                 if ps -C cyrus-master >/dev/null 2>&1; then
31                         RETVAL=$?
32                         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cyrus-imapd
33                         ok
34                 else
35                         fail
36                 fi
37         else
38                 msg_already_running cyrus-imapd
39         fi
40 }
41
42 stop() {
43         # Stop daemons.
44         if [ -f /var/lock/subsys/cyrus-imapd ]; then
45                 msg_stopping cyrus-imapd
46                 killproc cyrus-master
47                 rm -f /var/lock/subsys/cyrus-imapd
48         else
49                 msg_not_running cyrus-imapd
50         fi
51 }
52
53 condrestart() {
54         if [ -f /var/lock/subsys/cyrus-imapd ]; then
55                 stop
56                 start
57         else
58                 msg_not_running cyrus-imapd
59                 RETVAL=$1
60         fi
61 }
62
63 RETVAL=0
64 # See how we were called.
65 case "$1" in
66   start)
67         start
68         ;;
69   stop)
70         stop
71         ;;
72   restart)
73         stop
74         start
75   try-restart)
76         condrestart 0
77         ;;
78         ;;
79   force-reload)
80         condrestart 7
81         ;;
82   status)
83         status cyrus-master
84         RETVAL=$?
85         ;;
86   *)
87         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
88         exit 3
89 esac
90
91 exit $RETVAL
This page took 0.033591 seconds and 3 git commands to generate.