1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00
Andrew Tridgell b4f764c269 fixed error handling in event scripts
(This used to be ctdb commit d645c8b0480e7d2765614a226d78510e100016de)
2007-06-06 11:27:06 +10:00

52 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
############################
# main event script for ctdb
#
# This script is called with one of the following sets of arguments
# startup : called when ctdb starts
# shutdown : called when ctdb shuts down
# takeip : called when an IP address is taken over
# releaseip : called when an IP address is released
# recovered : called when ctdb has finished a recovery event
. /etc/ctdb/functions
loadconfig ctdb
# ensure we have /bin and /usr/bin in the path
PATH=/bin:/usr/bin:$PATH
cmd="$1"
shift
case $cmd in
startup)
# make sure we have a blank state directory for the scripts to work with
/bin/rm -rf /etc/ctdb/state
/bin/mkdir -p /etc/ctdb/state
# set any tunables from the config file
set | grep ^CTDB_SET_ | cut -d_ -f3- |
while read v; do
varname=`echo $v | cut -d= -f1`
value=`echo $v | cut -d= -f2`
ctdb setvar $varname $value || exit 1
echo "`date` Set $varname to $value"
done
;;
esac
#######################################
# call all application or local scripts
[ -d /etc/ctdb/events.d ] && {
# only accept scripts of the form NN.name
scripts=`/bin/ls /etc/ctdb/events.d | /bin/grep '^[0-9]*\.\w*$' | sort -n`
for SCRIPT in $scripts; do
[ -x /etc/ctdb/events.d/$SCRIPT ] && {
/etc/ctdb/events.d/$SCRIPT $cmd "$1" "$2" "$3" || exit 1
}
done
}
# all OK
exit 0