]> git.pld-linux.org Git - packages/ConferenceRoom.git/blob - cr.init
fix status
[packages/ConferenceRoom.git] / cr.init
1 #!/bin/sh
2 #
3 # cr    Conference Room IRC Daemon
4 #
5 # chkconfig:    345 56 44
6 #
7 # description:  Conference Room is a IRC Daemon
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 SERVICES="cr ws sv"
18
19 # Get service config - may override defaults
20 [ -f /etc/sysconfig/cr ] && . /etc/sysconfig/cr
21
22 # Check that networking is up.
23 if is_yes "${NETWORKING}"; then
24         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
25                 msg_network_down cr
26                 exit 1
27         fi
28 else
29         exit 0
30 fi
31
32 start() {
33         # Check if the service is already running?
34         if [ ! -f /var/lock/subsys/cr ]; then
35                 msg_starting "Conference Room IRC Daemon"; busy
36                 start-stop-daemon --start \
37                         --chdir /var/lib/cr \
38                         --exec /usr/lib/cr/programs/launcher \
39                         --chuid ircd \
40                         -- /var/lib/cr $SERVICES
41
42                 RETVAL=$?
43                 if [ $RETVAL -eq 0 ]; then
44                         # write proper pidfile as it itself probably writes parent pid which is no longer there
45                         pidfile=/var/lib/cr/CRServices.pid
46                         pid=$(ps -o pid= -C ConfRoom | head -n1)
47                         [ "$pid" ] && echo "$pid" > $pidfile
48                         ok
49                         touch /var/lock/subsys/cr
50                 else
51                         fail
52                 fi
53         else
54                 msg_already_running "Conference Room IRC Daemon"
55         fi
56 }
57
58 stop() {
59         if [ -f /var/lock/subsys/cr ]; then
60                 # Stop daemons.
61                 msg_stopping "Conference Room IRC Daemon"
62                 start-stop-daemon --stop --oknodo --pidfile /var/lib/cr/CRServices.pid && ok || fail
63                 rm -f /var/lock/subsys/cr
64         else
65                 msg_not_running "Conference Room IRC Daemon"
66         fi
67 }
68
69 condrestart() {
70         if [ -f /var/lock/subsys/cr ]; then
71                 stop
72                 start
73         else
74                 msg_not_running "Conference Room IRC Daemon"
75                 RETVAL=$1
76         fi
77 }
78
79 RETVAL=0
80 # See how we were called.
81 case "$1" in
82   start)
83         start
84         ;;
85   stop)
86         stop
87         ;;
88   restart)
89         stop
90         start
91         ;;
92   try-restart)
93         condrestart 0
94         ;;
95   force-reload)
96         condrestart 7
97         ;;
98   status)
99         status --pidfile /var/lib/cr/CRServices.pid cr ConfRoom
100         RETVAL=$?
101         ;;
102   *)
103         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
104         exit 3
105 esac
106
107 exit $RETVAL
This page took 0.1095 seconds and 3 git commands to generate.