]> TLD Linux GIT Repositories - packages/glusterfs.git/blob - glusterfsd.init
- updated to 10.5
[packages/glusterfs.git] / glusterfsd.init
1 #!/bin/sh
2 #
3 # glusterfsd    GlusterFS Daemon
4 #
5 # chkconfig:    345 14 89
6 #
7 # description:  GlusterFS Daemon
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/glusterfsd ] && . /etc/sysconfig/glusterfsd
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 glusterfsd
24                 exit 1
25         fi
26 else
27         exit 0
28 fi
29
30 test -x /usr/sbin/glusterfsd || exit 0
31
32 start() {
33         # Check if the service is already running?
34         if [ ! -f /var/lock/subsys/glusterfsd ]; then
35                 msg_starting glusterfsd
36                 daemon /usr/sbin/glusterfsd -p /var/run/glusterfsd.pid  
37                 RETVAL=$?
38                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/glusterfsd
39         else
40                 msg_already_running glusterfsd
41         fi
42 }
43
44
45 stop() {
46         if [ -f /var/lock/subsys/glusterfsd ]; then
47                 # Stop daemons.
48                 msg_stopping glusterfsd
49                 killproc --pidfile /var/run/glusterfsd.pid glusterfsd -TERM
50                 rm -f /var/lock/subsys/glusterfsd
51         # Killing remaining GlusterFS volume handling processes"
52         for PID in $(find /var/lib/glusterd/ -type f -name "*.pid" -exec cat {} \;); do
53             msg_stopping  "glusterfs volume daemon (${PID})"
54             ## TODO: Find pidfiles instead of pids and use:     killproc --pidfile ${PIDFILE} -TERM
55             kill -TERM ${PID}
56         done
57                 
58         else
59                 msg_not_running glusterfsd
60         fi
61 }
62
63 condrestart() {
64         if [ -f /var/lock/subsys/glusterfsd ]; then
65                 stop
66                 start
67         else
68                 msg_not_running glusterfsd
69                 RETVAL=$1
70         fi
71 }
72
73 RETVAL=0
74 # See how we were called.
75 case "$1" in
76   start)
77         start
78         ;;
79   stop)
80         stop
81         ;;
82   restart)
83         stop
84         start
85         ;;
86   try-restart)
87         condrestart 0
88         ;;
89   force-reload)
90         condrestart 7
91         ;;
92   status)
93         status glusterfsd
94         RETVAL=$?
95         # Listing volume daemons
96         ls -la /var/lib/glusterd/vols/*/run/*.pid
97         ;;
98   *)
99         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
100         exit 3
101 esac
102
103 exit $RETVAL