Update version according to OSCI-883
[packages/precise/mcollective.git] / mcollective.init
1 #!/bin/sh
2 #
3 # mcollective   Application Server for STOMP based agents
4 #
5 # chkconfig:    345 24 76
6 #
7 # description:  mcollective lets you build powerful Stomp compatible middleware clients in ruby without having to worry too
8 #               much about all the setup and management of a Stomp connection, it also provides stats, logging and so forth
9 #               as a bonus.
10 #
11 ### BEGIN INIT INFO
12 # Provides:          mcollective
13 # Required-Start:    $remote_fs
14 # Required-Stop:     $remote_fs
15 # Default-Start:     2 3 4 5
16 # Default-Stop:      0 1 6
17 # Short-Description: Start daemon at boot time
18 # Description:       Enable service provided by daemon.
19 ### END INIT INFO
20
21 mcollectived="/usr/sbin/mcollectived"
22
23 # Lockfile
24 if [ -d /var/lock/subsys ]; then
25     # RedHat/CentOS/etc who use subsys
26     lock="/var/lock/subsys/mcollective"
27 else
28     # The rest of them
29     lock="/var/lock/mcollective"
30 fi
31
32
33 # PID directory
34 pidfile="/var/run/mcollectived.pid"
35
36 # Source function library.
37 . /lib/lsb/init-functions
38
39 # Check that binary exists
40 if ! [ -f $mcollectived ]
41 then
42     echo "mcollectived binary not found"
43     exit 0
44 fi
45
46 # See how we were called.
47 case "$1" in
48     start)
49         echo -n "Starting mcollective: "
50
51         if [ -f ${lock} ]; then
52             # we were not shut down correctly
53             if [ -s ${pidfile} ]; then
54                 kill `cat ${pidfile}` >/dev/null 2>&1
55             fi
56             rm -f ${pidfile}
57
58             rm -f ${lock}
59             sleep 2
60         fi
61
62         rm -f ${pidfile}
63
64         ${mcollectived} --pid=${pidfile} --config="/etc/mcollective/server.cfg"
65         if [ $? = 0 ]; then
66             log_success_msg
67             touch $lock
68             exit 0
69         else
70             log_failure_msg
71             exit 1
72         fi
73         ;;
74     stop)
75         echo -n "Shutting down mcollective: "
76
77         if [ -s ${pidfile} ]; then
78             kill `cat ${pidfile}` >/dev/null 2>&1
79         fi
80         rm -f ${pidfile}
81
82         log_success_msg
83         rm -f $lock
84         ;;
85     restart)
86         $0 stop
87         sleep 2
88         $0 start
89         ;;
90     condrestart)
91         if [ -f $lock ]; then
92             $0 stop
93             # avoid race
94             sleep 2
95             $0 start
96         fi
97         ;;
98     status)
99         if [ -f ${lock} ]; then
100             if [ -s ${pidfile} ]; then
101                 if [ -e /proc/`cat ${pidfile}` ]; then
102                     echo "mcollectived (`cat ${pidfile}`) is running"
103                     exit 0
104                 else
105                     echo "mcollectived (`cat ${pidfile}`) is NOT running"
106                     exit 1
107                 fi
108             fi
109         else
110             echo "mcollectived: service not started"
111             exit 1
112         fi
113         ;;
114     force-reload)
115         echo "not implemented"
116         ;;
117     *)
118         echo "Usage: mcollectived {start|stop|restart|condrestart|status}"
119         exit 1
120         ;;
121 esac
122 exit 0