mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
62b30e478d
(This used to be ctdb commit dde9024b25fe12cf25c059e5accb3ca21838b130)
147 lines
3.2 KiB
Bash
Executable File
147 lines
3.2 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
|
|
|
|
[ -f /etc/rc.status ] && {
|
|
. /etc/rc.status
|
|
rc_reset
|
|
LC_ALL=en_US.UTF-8
|
|
}
|
|
|
|
# Avoid using root's TMPDIR
|
|
unset TMPDIR
|
|
|
|
. /etc/ctdb/functions
|
|
loadconfig network
|
|
loadconfig ctdb
|
|
|
|
# check networking is up (for redhat)
|
|
[ "${NETWORKING}" = "no" ] && exit 0
|
|
|
|
CTDB_OPTIONS=""
|
|
|
|
[ -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 "$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"
|
|
|
|
if [ -x /sbin/startproc ]; then
|
|
init_style="suse"
|
|
else if [ -x /sbin/start-stop-daemon ]; then
|
|
init_style="ubuntu"
|
|
else
|
|
init_style="redhat"
|
|
fi
|
|
fi
|
|
|
|
start() {
|
|
killall -q ctdbd
|
|
echo -n $"Starting ctdbd service: "
|
|
case $init_style in
|
|
suse)
|
|
startproc /usr/sbin/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
|
|
;;
|
|
ubuntu)
|
|
start-stop-daemon --start --quiet --background --exec /usr/sbin/ctdbd -- $CTDB_OPTIONS
|
|
return $?
|
|
;;
|
|
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)
|
|
status
|
|
;;
|
|
condrestart)
|
|
ctdb status > /dev/null && restart || :
|
|
;;
|
|
cron)
|
|
# used from cron to auto-restart ctdb
|
|
ctdb status > /dev/null || restart
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|status|cron|condrestart}"
|
|
exit 1
|
|
esac
|
|
|
|
exit $?
|