mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
643b87fbae
(This used to be ctdb commit 8396a7500225c90165ebcfbdc2c65673740e6b25)
97 lines
1.9 KiB
Bash
Executable File
97 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
#################################
|
|
# interface event script for ctdb
|
|
# this adds/removes IPs from your
|
|
# public interface
|
|
|
|
. /etc/ctdb/functions
|
|
loadconfig ctdb
|
|
|
|
cmd="$1"
|
|
shift
|
|
|
|
[ -z "$CTDB_PUBLIC_INTERFACE" ] && {
|
|
[ "$cmd" = "startup" ] && {
|
|
echo "Event script $0 : CTDB_PUBLIC_INTERFACE not set. Nothing to do."
|
|
}
|
|
exit 0
|
|
}
|
|
|
|
|
|
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/$maskbits 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 the public network interface $CTDB_PUBLIC_INTERFACE"
|
|
exit 1
|
|
}
|
|
}
|
|
;;
|
|
|
|
esac
|
|
|
|
exit 0
|