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