1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
samba-mirror/ctdb/config/events.d/10.interface
Andrew Tridgell 76b7361c7e - added monitoring of rpc ports for nfs, and of Samba ports and directories
- added monitoring of the ethernet link state

When monitoring detects an error, the node loses its public IP address

(This used to be ctdb commit 0af57aead8c983511d25774b4ffe09fa5ff26501)
2007-06-06 12:08:42 +10:00

91 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
#################################
# interface event script for ctdb
# this adds/removes IPs from your
# public interface
. /etc/ctdb/functions
loadconfig ctdb
[ -z "$CTDB_PUBLIC_INTERFACE" ] && exit 0
cmd="$1"
shift
case $cmd in
#############################
# called when ctdbd starts up
startup)
;;
################################################
# 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
# we make sure the interface is up first
/sbin/ip link set $iface up || {
echo "`/bin/date` Failed to bringup interface $iface"
exit 1
}
/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)
;;
monitor)
[ -x /usr/sbin/ethtool ] && {
/usr/sbin/ethtool $CTDB_PUBLIC_INTERFACE | grep 'Link detected: yes' > /dev/null || {
echo "`date` ERROR: No link on network interface $CTDB_PUBLIC_INTERFACE"
exit 1
}
}
;;
esac
exit 0