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
# Avoid using root's TMPDIR
unset TMPDIR
2007-06-01 17:25:33 +04:00
# check networking is up (for redhat)
[ -f /etc/sysconfig/network ] && {
. /etc/sysconfig/network
[ ${NETWORKING} = "no" ] && exit 0
}
2007-05-28 00:48:18 +04:00
2007-05-29 10:02:02 +04:00
CTDB_OPTIONS=""
2007-06-01 17:25:33 +04:00
# pull in admin specified config for ctdb
2007-05-28 00:48:18 +04:00
if [ -f /etc/sysconfig/ctdb ]; then
. /etc/sysconfig/ctdb
fi
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-05-29 09:36:42 +04:00
[ -z "$LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$LOGFILE"
[ -z "$NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$NODES"
2007-05-29 10:02:02 +04:00
[ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
[ -z "$PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$PUBLIC_ADDRESSES"
2007-05-29 09:36:42 +04:00
[ -z "$PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$PUBLIC_INTERFACE"
[ -z "$DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$DBDIR"
2007-05-29 10:02:02 +04:00
[ -z "$EVENT_SCRIPT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script $EVENT_SCRIPT"
[ -z "$TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $TRANSPORT"
2007-05-29 09:36:42 +04:00
[ -z "$DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $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"
else
init_style="redhat"
fi
2007-05-28 00:48:18 +04:00
start() {
2007-06-01 17:25:33 +04:00
echo -n $"Starting ctdbd service: "
case $init_style in
suse)
startproc ctdbd $CTDB_OPTIONS
rc_status -v
;;
redhat)
daemon ctdbd $CTDB_OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
return $RETVAL
;;
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)
rhstatus
;;
condrestart)
2007-06-01 17:25:33 +04:00
ctdb status > /dev/null && restart || :
2007-05-28 00:48:18 +04:00
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"
exit 1
esac
exit $?