2007-05-28 00:48:18 +04:00
#!/bin/sh
#
2007-06-01 17:25:33 +04:00
##############################
# init info for redhat distros
2007-05-28 19:38:04 +04:00
# chkconfig: - 90 36
# description: Starts and stops the clustered tdb daemon
# pidfile: /var/run/ctdbd/ctdbd.pid
2007-06-01 17:25:33 +04:00
##############################
##############################
# SLES/OpenSuSE init info
### BEGIN INIT INFO
# Provides: ctdb
# Required-Start: $network
# Required-Stop:
# Default-Start: 3 5
# Default-Stop:
# Description: initscript for the ctdb service
### END INIT INFO
2007-05-28 00:48:18 +04:00
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
fi
2007-06-03 11:53:26 +04:00
[ -f /etc/rc.status ] && {
. /etc/rc.status
rc_reset
LC_ALL=en_US.UTF-8
}
2007-05-28 00:48:18 +04:00
# Avoid using root's TMPDIR
unset TMPDIR
2007-06-03 16:07:07 +04:00
. /etc/ctdb/functions
loadconfig network
loadconfig ctdb
2007-06-01 17:25:33 +04:00
# check networking is up (for redhat)
2007-06-03 16:11:48 +04:00
[ "${NETWORKING}" = "no" ] && exit 0
2007-05-28 00:48:18 +04:00
2007-06-02 05:36:42 +04:00
[ -z "$CTDB_RECOVERY_LOCK" ] && {
echo "You must configure the location of the CTDB_RECOVERY_LOCK"
exit 1
}
CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
# build up CTDB_OPTIONS variable from optional parameters
2007-06-04 09:44:52 +04:00
[ -z "$CTDB_LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$CTDB_LOGFILE"
[ -z "$CTDB_NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$CTDB_NODES"
[ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
[ -z "$CTDB_PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$CTDB_PUBLIC_ADDRESSES"
[ -z "$CTDB_PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$CTDB_PUBLIC_INTERFACE"
[ -z "$CTDB_DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$CTDB_DBDIR"
[ -z "$CTDB_EVENT_SCRIPT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script $CTDB_EVENT_SCRIPT"
[ -z "$CTDB_TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $CTDB_TRANSPORT"
[ -z "$CTDB_DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $CTDB_DEBUGLEVEL"
2007-05-28 00:48:18 +04:00
2007-06-01 17:25:33 +04:00
if [ -x /sbin/startproc ]; then
init_style="suse"
2007-06-03 13:24:52 +04:00
else if [ -x /sbin/start-stop-daemon ]; then
init_style="ubuntu"
else
init_style="redhat"
fi
2007-06-01 17:25:33 +04:00
fi
2007-05-28 00:48:18 +04:00
start() {
2007-06-02 13:40:07 +04:00
killall -q ctdbd
2007-06-01 17:25:33 +04:00
echo -n $"Starting ctdbd service: "
case $init_style in
suse)
2007-06-03 11:53:26 +04:00
startproc /usr/sbin/ctdbd $CTDB_OPTIONS
2007-06-01 17:25:33 +04:00
rc_status -v
;;
redhat)
daemon ctdbd $CTDB_OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
return $RETVAL
;;
2007-06-03 13:24:52 +04:00
ubuntu)
start-stop-daemon --start --quiet --background --exec /usr/sbin/ctdbd -- $CTDB_OPTIONS
return $?
;;
2007-06-01 17:25:33 +04:00
esac
2007-05-28 00:48:18 +04:00
}
stop() {
2007-06-01 17:25:33 +04:00
echo -n $"Shutting down ctdbd service: "
2007-05-29 09:36:42 +04:00
ctdb shutdown
2007-05-28 00:48:18 +04:00
RETVAL=$?
2007-06-01 17:25:33 +04:00
case $init_style in
suse)
rc_status -v
;;
redhat)
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
echo ""
return $RETVAL
;;
esac
2007-05-28 00:48:18 +04:00
}
restart() {
stop
start
}
2007-06-01 17:25:33 +04:00
status() {
2007-05-29 09:36:42 +04:00
ctdb status
2007-05-28 00:48:18 +04:00
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
2007-06-02 12:51:05 +04:00
status
2007-05-28 00:48:18 +04:00
;;
condrestart)
2007-06-01 17:25:33 +04:00
ctdb status > /dev/null && restart || :
2007-05-28 00:48:18 +04:00
;;
2007-06-02 12:51:05 +04:00
cron)
# used from cron to auto-restart ctdb
2007-06-03 04:29:57 +04:00
ctdb status > /dev/null || restart
2007-06-02 12:51:05 +04:00
;;
2007-05-28 00:48:18 +04:00
*)
2007-06-02 12:51:05 +04:00
echo $"Usage: $0 {start|stop|restart|status|cron|condrestart}"
2007-05-28 00:48:18 +04:00
exit 1
esac
exit $?