1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/ctdb/packaging/ctdb.init
Andrew Tridgell ebf12646cf - make specification of a recovery lock file compulsory
- die if someone other than the recmaster can get the recovery lock

(This used to be ctdb commit a827d0d0e430ca8ad5d521367e45097185492869)
2007-06-02 11:36:42 +10:00

133 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
#
##############################
# init info for redhat distros
# chkconfig: - 90 36
# description: Starts and stops the clustered tdb daemon
# pidfile: /var/run/ctdbd/ctdbd.pid
##############################
##############################
# 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
# 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
# check networking is up (for redhat)
[ -f /etc/sysconfig/network ] && {
. /etc/sysconfig/network
[ ${NETWORKING} = "no" ] && exit 0
}
CTDB_OPTIONS=""
# pull in admin specified config for ctdb
if [ -f /etc/sysconfig/ctdb ]; then
. /etc/sysconfig/ctdb
fi
[ -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
[ -z "$LOGFILE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --logfile=$LOGFILE"
[ -z "$NODES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --nlist=$NODES"
[ -z "$CTDB_SOCKET" ] || CTDB_OPTIONS="$CTDB_OPTIONS --socket=$CTDB_SOCKET"
[ -z "$PUBLIC_ADDRESSES" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-addresses=$PUBLIC_ADDRESSES"
[ -z "$PUBLIC_INTERFACE" ] || CTDB_OPTIONS="$CTDB_OPTIONS --public-interface=$PUBLIC_INTERFACE"
[ -z "$DBDIR" ] || CTDB_OPTIONS="$CTDB_OPTIONS --dbdir=$DBDIR"
[ -z "$EVENT_SCRIPT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --event-script $EVENT_SCRIPT"
[ -z "$TRANSPORT" ] || CTDB_OPTIONS="$CTDB_OPTIONS --transport $TRANSPORT"
[ -z "$DEBUGLEVEL" ] || CTDB_OPTIONS="$CTDB_OPTIONS -d $DEBUGLEVEL"
if [ -x /sbin/startproc ]; then
init_style="suse"
else
init_style="redhat"
fi
start() {
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
}
stop() {
echo -n $"Shutting down ctdbd service: "
ctdb shutdown
RETVAL=$?
case $init_style in
suse)
rc_status -v
;;
redhat)
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
echo ""
return $RETVAL
;;
esac
}
restart() {
stop
start
}
status() {
ctdb status
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rhstatus
;;
condrestart)
ctdb status > /dev/null && restart || :
;;
*)
echo $"Usage: $0 {start|stop|restart|status|condrestart}"
exit 1
esac
exit $?