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"
loadconfig "network"
loadconfig "ctdb"
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
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}"
pidfile="${CTDB_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
{
2013-07-09 09:22:07 +04:00
echo -n "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 \
"$ctdbd_wrapper" "$pidfile" "start"
rc_status -v
2009-07-07 07:45:19 +04:00
;;
redhat)
2013-07-09 09:22:07 +04:00
daemon --pidfile "$pidfile" \
"$ctdbd_wrapper" "$pidfile" "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 \
"$ctdbd_wrapper" "$pidfile" "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()
{
echo -n "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)
2013-07-09 09:22:07 +04:00
"$ctdbd_wrapper" "$pidfile" "stop"
2009-07-07 07:45:19 +04:00
rc_status -v
;;
redhat)
2013-07-09 09:22:07 +04:00
"$ctdbd_wrapper" "$pidfile" "stop"
RETVAL=$?
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)
"$ctdbd_wrapper" "$pidfile" "stop"
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 ()
{
# Backward compatibility. When we arrange to pass --pidfile to
# ctdbd we also create the directory that will contain it. If
# that directory is missing then we don't use the pidfile to check
2013-07-09 09:22:07 +04:00
# status. Note that this probably won't work if
# $CTDB_VALGRIND="yes" but this doesn't need full backward
# compatibility because it is a debug option.
2013-04-15 09:18:12 +04:00
if [ -d $(dirname "$pidfile") ] ; then
_pf_opt="-p $pidfile"
else
_pf_opt=""
fi
2013-07-09 09:22:07 +04:00
case "$CTDB_INIT_STYLE" in
2013-04-15 09:18:12 +04:00
suse)
checkproc $_pf_opt "$ctdbd"
rc_status -v
;;
redhat)
status $_pf_opt -l "ctdb" "$ctdbd"
;;
debian)
status_of_proc $_pf_opt "$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