]>
Commit | Line | Data |
---|---|---|
3f05bde6 MK |
1 | #!/bin/sh |
2 | # | |
3 | # glusterfsd Cassandra | |
4 | # | |
5 | # chkconfig: 345 14 89 | |
6 | # | |
7 | # description: Cassandra database node | |
8 | # | |
9 | ||
10 | # Source function library | |
11 | . /etc/rc.d/init.d/functions | |
12 | ||
13 | # Get network config | |
14 | . /etc/sysconfig/network | |
15 | ||
16 | ||
17 | # Get service config - may override defaults | |
18 | # [ -f /etc/sysconfig/cassandra ] && . /etc/sysconfig/cassandra | |
19 | ||
20 | # Check that networking is up. | |
21 | if is_yes "${NETWORKING}"; then | |
22 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then | |
23 | msg_network_down cassandra | |
24 | exit 1 | |
25 | fi | |
26 | else | |
27 | exit 0 | |
28 | fi | |
29 | ||
30 | test -x /usr/sbin/cassandra || exit 0 | |
31 | ||
32 | start() { | |
33 | # Check if the service is already running? | |
34 | if [ ! -f /var/lock/subsys/cassandra ]; then | |
35 | msg_starting cassandra | |
36 | daemon /usr/sbin/cassandra -p /var/run/cassandra.pid | |
37 | RETVAL=$? | |
38 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cassandra | |
39 | else | |
40 | msg_already_running cassandra | |
41 | fi | |
42 | } | |
43 | ||
44 | ||
45 | stop() { | |
46 | if [ -f /var/lock/subsys/cassandra ]; then | |
47 | # Stop daemons. | |
48 | msg_stopping cassandra | |
49 | killproc --pidfile /var/run/cassandra.pid cassandra -TERM | |
50 | rm -f /var/lock/subsys/cassandra | |
51 | else | |
52 | msg_not_running cassandra | |
53 | fi | |
54 | } | |
55 | ||
56 | condrestart() { | |
57 | if [ -f /var/lock/subsys/cassandra ]; then | |
58 | stop | |
59 | start | |
60 | else | |
61 | msg_not_running cassandra | |
62 | RETVAL=$1 | |
63 | fi | |
64 | } | |
65 | ||
66 | RETVAL=0 | |
67 | # See how we were called. | |
68 | case "$1" in | |
69 | start) | |
70 | start | |
71 | ;; | |
72 | stop) | |
73 | stop | |
74 | ;; | |
75 | restart) | |
76 | stop | |
77 | start | |
78 | ;; | |
79 | try-restart) | |
80 | condrestart 0 | |
81 | ;; | |
82 | force-reload) | |
83 | condrestart 7 | |
84 | ;; | |
85 | status) | |
86 | # Does not work with /usr/sbin/cassandra for some reason | |
87 | status cassandra | |
88 | ;; | |
89 | *) | |
90 | # msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" | |
91 | msg_usage "$0 {start|stop|restart|try-restart|force-reload}" | |
92 | exit 3 | |
93 | esac | |
94 | ||
95 | exit $RETVAL |