1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00
samba-mirror/ctdb/config/events
Andrew Tridgell fcce534f23 allow setting of variables at startup in config file
(This used to be ctdb commit db39ca7c0ee1441113ac3279cb75b3cb38eecd1b)
2007-06-04 20:05:31 +10:00

50 lines
1.2 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
. /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
/bin/ls /etc/ctdb/events.d | /bin/grep '^[0-9]*\.\w*$' | sort -n |
while read SCRIPT; do
[ -x /etc/ctdb/events.d/$SCRIPT ] && {
/etc/ctdb/events.d/$SCRIPT $cmd "$1" "$2" "$3" || exit 1
}
done
}
# all OK
exit 0