2007-05-28 00:48:18 +04:00
#!/bin/sh
2013-07-09 09:22:07 +04:00
# Start and stop CTDB (Clustered TDB daemon)
2007-05-28 00:48:18 +04:00
#
2013-07-09 09:22:07 +04:00
# chkconfig: - 90 01
2008-08-25 04:13:18 +04:00
#
2013-07-09 09:22:07 +04:00
# description: Starts and stops CTDB
# pidfile: /var/run/ctdb/ctdbd.pid
# config: /etc/sysconfig/ctdb
2007-06-01 17:25:33 +04:00
### BEGIN INIT INFO
2008-08-25 04:13:18 +04:00
# Provides: ctdb
2013-08-29 10:20:05 +04:00
# Required-Start: $local_fs $syslog $network $remote_fs
# Required-Stop: $local_fs $syslog $network $remote_fs
2013-07-09 09:22:07 +04:00
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2008-08-25 04:13:18 +04:00
# Short-Description: start and stop ctdb service
2013-07-09 09:22:07 +04:00
# Description: Start and stop CTDB (Clustered TDB daemon)
2007-06-01 17:25:33 +04:00
### END INIT INFO
2007-05-28 00:48:18 +04:00
# Source function library.
if [ -f /etc/init.d/functions ] ; then
2013-07-09 09:22:07 +04:00
# Red Hat
2009-07-07 07:45:19 +04:00
. /etc/init.d/functions
2007-05-28 00:48:18 +04:00
elif [ -f /etc/rc.d/init.d/functions ] ; then
2013-07-09 09:22:07 +04:00
# Red Hat
2009-07-07 07:45:19 +04:00
. /etc/rc.d/init.d/functions
2013-07-09 09:22:07 +04:00
elif [ -f /etc/rc.status ] ; then
# SUSE
2007-06-03 11:53:26 +04:00
. /etc/rc.status
rc_reset
LC_ALL=en_US.UTF-8
2013-07-09 09:22:07 +04:00
elif [ -f /lib/lsb/init-functions ] ; then
# Debian
2013-04-15 09:18:12 +04:00
. /lib/lsb/init-functions
fi
2007-05-28 00:48:18 +04:00
# Avoid using root's TMPDIR
unset TMPDIR
2013-07-09 09:22:07 +04:00
[ -n "$CTDB_BASE" ] || export CTDB_BASE="/etc/ctdb"
2007-09-14 08:14:03 +04:00
2013-07-09 09:22:07 +04:00
. "${CTDB_BASE}/functions"
2018-02-06 03:25:56 +03:00
load_system_config "network"
2007-06-03 16:07:07 +04:00
2009-07-07 07:45:19 +04:00
# check networking is up (for redhat)
2013-07-09 09:22:07 +04:00
if [ "$NETWORKING" = "no" ] ; then
exit 0
fi
2007-05-28 00:48:18 +04:00
2018-02-06 03:25:56 +03:00
load_system_config "ctdb"
2009-01-16 15:28:19 +03:00
detect_init_style
export CTDB_INIT_STYLE
2013-07-09 09:22:07 +04:00
ctdbd="${CTDBD:-/usr/sbin/ctdbd}"
ctdbd_wrapper="${CTDBD_WRAPPER:-/usr/sbin/ctdbd_wrapper}"
2018-03-05 13:26:07 +03:00
pidfile="/var/run/ctdb/ctdbd.pid"
2009-07-07 07:45:19 +04:00
2013-07-09 09:22:07 +04:00
############################################################
2009-07-07 07:45:19 +04:00
2013-07-09 09:22:07 +04:00
start()
2013-02-05 08:49:52 +04:00
{
2016-07-06 23:41:27 +03:00
printf "Starting ctdbd service: "
2009-07-07 07:45:19 +04:00
2013-07-09 09:22:07 +04:00
case "$CTDB_INIT_STYLE" in
2009-07-07 07:45:19 +04:00
suse)
2013-07-09 09:22:07 +04:00
startproc \
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "start"
2013-07-09 09:22:07 +04:00
rc_status -v
2009-07-07 07:45:19 +04:00
;;
redhat)
2013-07-09 09:22:07 +04:00
daemon --pidfile "$pidfile" \
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "start"
2009-07-07 07:45:19 +04:00
RETVAL=$?
2013-07-09 09:22:07 +04:00
echo
2009-07-07 07:45:19 +04:00
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
2013-07-09 09:22:07 +04:00
return $RETVAL
2009-07-07 07:45:19 +04:00
;;
2009-09-15 13:33:35 +04:00
debian)
2013-07-09 09:22:07 +04:00
eval start-stop-daemon --start --quiet --background --exec \
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "start"
2009-07-07 07:45:19 +04:00
;;
esac
2010-02-22 06:06:52 +03:00
}
2008-05-12 10:44:33 +04:00
2013-07-09 09:22:07 +04:00
stop()
{
2016-07-06 23:41:27 +03:00
printf "Shutting down ctdbd service: "
2013-04-15 09:18:12 +04:00
2013-07-09 09:22:07 +04:00
case "$CTDB_INIT_STYLE" in
2009-07-07 07:45:19 +04:00
suse)
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "stop"
2009-07-07 07:45:19 +04:00
rc_status -v
;;
redhat)
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "stop"
2013-07-09 09:22:07 +04:00
RETVAL=$?
2016-07-06 13:40:23 +03:00
# Common idiom in Red Hat init scripts - success() always
# succeeds so this does behave like if-then-else
# shellcheck disable=SC2015
2009-10-16 09:35:56 +04:00
[ $RETVAL -eq 0 ] && success || failure
2009-07-07 07:45:19 +04:00
echo ""
2013-07-09 09:22:07 +04:00
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
return $RETVAL
;;
debian)
2018-03-05 13:02:40 +03:00
"$ctdbd_wrapper" "stop"
2013-07-09 09:22:07 +04:00
log_end_msg $?
2009-07-07 07:45:19 +04:00
;;
esac
}
2008-01-04 04:41:53 +03:00
2013-07-09 09:22:07 +04:00
restart()
{
2009-07-07 07:45:19 +04:00
stop
start
2010-02-22 06:06:52 +03:00
}
2007-05-28 00:48:18 +04:00
2013-04-15 09:18:12 +04:00
check_status ()
{
2018-03-05 13:01:17 +03:00
case "$CTDB_INIT_STYLE" in
2013-04-15 09:18:12 +04:00
suse)
2018-03-05 13:01:17 +03:00
checkproc -p "$pidfile" "$ctdbd"
rc_status -v
;;
2013-04-15 09:18:12 +04:00
redhat)
2018-03-05 13:01:17 +03:00
status -p "$pidfile" -l "ctdb" "$ctdbd"
;;
2013-04-15 09:18:12 +04:00
debian)
2018-03-05 13:01:17 +03:00
status_of_proc -p "$pidfile" "$ctdbd" "ctdb"
;;
esac
2009-07-07 07:45:19 +04:00
}
2007-05-28 00:48:18 +04:00
2013-07-09 09:22:07 +04:00
############################################################
2012-02-06 05:07:08 +04:00
2009-12-01 09:43:47 +03:00
case "$1" in
2009-07-07 07:45:19 +04:00
start)
2007-05-28 00:48:18 +04:00
start
;;
2009-07-07 07:45:19 +04:00
stop)
2007-05-28 00:48:18 +04:00
stop
;;
2010-02-22 06:06:52 +03:00
restart|reload|force-reload)
2007-05-28 00:48:18 +04:00
restart
;;
2009-07-07 07:45:19 +04:00
status)
2013-04-15 09:18:12 +04:00
check_status
2007-05-28 00:48:18 +04:00
;;
2010-02-22 06:06:52 +03:00
condrestart|try-restart)
2013-04-15 09:18:12 +04:00
if check_status >/dev/null ; then
restart
fi
2007-05-28 00:48:18 +04:00
;;
2009-07-07 07:45:19 +04:00
cron)
2007-06-02 12:51:05 +04:00
# used from cron to auto-restart ctdb
2013-07-09 09:22:07 +04:00
check_status >/dev/null 2>&1 || restart
2007-06-02 12:51:05 +04:00
;;
2009-07-07 07:45:19 +04:00
*)
2013-07-09 09:22:07 +04:00
echo "Usage: $0 {start|stop|restart|reload|force-reload|status|cron|condrestart|try-restart}"
2007-05-28 00:48:18 +04:00
exit 1
esac