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 794d6dd59d move config files to config/ directory
(This used to be ctdb commit f95de519b885c8e1f40df0cda70fd796e479a22a)
2007-06-02 19:40:07 +10:00

90 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
############################
# main event script for ctdb
. /etc/sysconfig/ctdb
. /etc/ctdb/functions
cmd="$1"
shift
case $cmd in
#############################
# called when ctdbd starts up
startup)
/bin/rm -rf /etc/ctdb/state
/bin/mkdir -p /etc/ctdb/state
;;
################################################
# called when ctdbd wants to claim an IP address
takeip)
if [ $# != 3 ]; then
echo "must supply interface, IP and maskbits"
exit 1
fi
iface=$1
ip=$2
maskbits=$3
/sbin/ip addr add $ip/$maskbits dev $iface || {
echo "`/bin/date` Failed to add $ip/$maskbits on dev $iface"
exit 1
}
# flush our route cache
echo 1 > /proc/sys/net/ipv4/route/flush
;;
##################################################
# called when ctdbd wants to release an IP address
releaseip)
if [ $# != 3 ]; then
echo "`/bin/date` must supply interface, IP and maskbits"
exit 1
fi
iface=$1
ip=$2
maskbits=$3
/sbin/ip addr del $ip dev $iface || {
echo "`/bin/date` Failed to del $ip on dev $iface"
exit 1
}
# flush our route cache
echo 1 > /proc/sys/net/ipv4/route/flush
;;
###########################################
# called when ctdbd has finished a recovery
recovered)
;;
####################################
# called when ctdbd is shutting down
shutdown)
;;
*)
echo "`/bin/date` Invalid ctdb event command $cmd"
exit 1
;;
esac
#######################################
# call all application specific scripts
[ -d /etc/ctdb/events.d ] && {
/bin/ls /etc/ctdb/events.d | /bin/grep -v '~' |
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