s3/rpc_client: Fix array offset check
[Samba.git] / ctdb / config / ctdb.init
blob6a7f7812394d3025e7512fc197de23d22a02a628
1 #!/bin/sh
3 # Start and stop CTDB (Clustered TDB daemon)
5 # chkconfig: - 90 01
7 # description: Starts and stops CTDB
8 # pidfile: /var/run/ctdb/ctdbd.pid
9 # config: /etc/sysconfig/ctdb
11 ### BEGIN INIT INFO
12 # Provides: ctdb
13 # Required-Start: $local_fs $syslog $network $remote_fs
14 # Required-Stop: $local_fs $syslog $network $remote_fs
15 # Default-Start: 2 3 4 5
16 # Default-Stop: 0 1 6
17 # Short-Description: start and stop ctdb service
18 # Description: Start and stop CTDB (Clustered TDB daemon)
19 ### END INIT INFO
21 # Source function library.
22 if [ -f /etc/init.d/functions ] ; then
23 # Red Hat
24 . /etc/init.d/functions
25 elif [ -f /etc/rc.d/init.d/functions ] ; then
26 # Red Hat
27 . /etc/rc.d/init.d/functions
28 elif [ -f /etc/rc.status ] ; then
29 # SUSE
30 . /etc/rc.status
31 rc_reset
32 LC_ALL=en_US.UTF-8
33 elif [ -f /lib/lsb/init-functions ] ; then
34 # Debian
35 . /lib/lsb/init-functions
38 # Avoid using root's TMPDIR
39 unset TMPDIR
41 [ -n "$CTDB_BASE" ] || export CTDB_BASE="/etc/ctdb"
43 . "${CTDB_BASE}/functions"
45 load_system_config "network"
47 # check networking is up (for redhat)
48 if [ "$NETWORKING" = "no" ] ; then
49 exit 0
52 load_system_config "ctdb"
54 detect_init_style
55 export CTDB_INIT_STYLE
57 ctdbd="${CTDBD:-/usr/sbin/ctdbd}"
58 ctdb="${CTDB:-/usr/bin/ctdb}"
59 pidfile="/var/run/ctdb/ctdbd.pid"
61 ############################################################
63 start()
65 printf "Starting ctdbd service: "
67 case "$CTDB_INIT_STYLE" in
68 suse)
69 startproc "$ctdbd"
70 rc_status -v
72 redhat)
73 daemon --pidfile "$pidfile" "$ctdbd"
74 RETVAL=$?
75 echo
76 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
77 return $RETVAL
79 debian)
80 eval start-stop-daemon --start --quiet --background --exec "$ctdbd"
82 esac
85 stop()
87 printf "Shutting down ctdbd service: "
89 case "$CTDB_INIT_STYLE" in
90 suse)
91 "$ctdb" "shutdown"
92 rc_status -v
94 redhat)
95 "$ctdb" "shutdown"
96 RETVAL=$?
97 # Common idiom in Red Hat init scripts - success() always
98 # succeeds so this does behave like if-then-else
99 # shellcheck disable=SC2015
100 [ $RETVAL -eq 0 ] && success || failure
101 echo ""
102 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
103 return $RETVAL
105 debian)
106 "$ctdb" "shutdown"
107 log_end_msg $?
109 esac
112 restart()
114 stop
115 start
118 check_status ()
120 case "$CTDB_INIT_STYLE" in
121 suse)
122 checkproc -p "$pidfile" "$ctdbd"
123 rc_status -v
125 redhat)
126 status -p "$pidfile" -l "ctdb" "$ctdbd"
128 debian)
129 status_of_proc -p "$pidfile" "$ctdbd" "ctdb"
131 esac
134 ############################################################
136 case "$1" in
137 start)
138 start
140 stop)
141 stop
143 restart|reload|force-reload)
144 restart
146 status)
147 check_status
149 condrestart|try-restart)
150 if check_status >/dev/null ; then
151 restart
154 cron)
155 # used from cron to auto-restart ctdb
156 check_status >/dev/null 2>&1 || restart
159 echo "Usage: $0 {start|stop|restart|reload|force-reload|status|cron|condrestart|try-restart}"
160 exit 1
161 esac