wafsamba: fix pidl dependencies to rebuild on pidl changes
[Samba.git] / ctdb / config / ctdb.init
blob7fe8f0085ae33fa9d28f7a60272938a0b7a8439c
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 ctdbd_wrapper="${CTDBD_WRAPPER:-/usr/sbin/ctdbd_wrapper}"
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 \
70 "$ctdbd_wrapper" "start"
71 rc_status -v
73 redhat)
74 daemon --pidfile "$pidfile" \
75 "$ctdbd_wrapper" "start"
76 RETVAL=$?
77 echo
78 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
79 return $RETVAL
81 debian)
82 eval start-stop-daemon --start --quiet --background --exec \
83 "$ctdbd_wrapper" "start"
85 esac
88 stop()
90 printf "Shutting down ctdbd service: "
92 case "$CTDB_INIT_STYLE" in
93 suse)
94 "$ctdbd_wrapper" "stop"
95 rc_status -v
97 redhat)
98 "$ctdbd_wrapper" "stop"
99 RETVAL=$?
100 # Common idiom in Red Hat init scripts - success() always
101 # succeeds so this does behave like if-then-else
102 # shellcheck disable=SC2015
103 [ $RETVAL -eq 0 ] && success || failure
104 echo ""
105 [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
106 return $RETVAL
108 debian)
109 "$ctdbd_wrapper" "stop"
110 log_end_msg $?
112 esac
115 restart()
117 stop
118 start
121 check_status ()
123 case "$CTDB_INIT_STYLE" in
124 suse)
125 checkproc -p "$pidfile" "$ctdbd"
126 rc_status -v
128 redhat)
129 status -p "$pidfile" -l "ctdb" "$ctdbd"
131 debian)
132 status_of_proc -p "$pidfile" "$ctdbd" "ctdb"
134 esac
137 ############################################################
139 case "$1" in
140 start)
141 start
143 stop)
144 stop
146 restart|reload|force-reload)
147 restart
149 status)
150 check_status
152 condrestart|try-restart)
153 if check_status >/dev/null ; then
154 restart
157 cron)
158 # used from cron to auto-restart ctdb
159 check_status >/dev/null 2>&1 || restart
162 echo "Usage: $0 {start|stop|restart|reload|force-reload|status|cron|condrestart|try-restart}"
163 exit 1
164 esac