ctdb-scripts: New eventscript 10.external
[Samba.git] / ctdb / config / events.d / 10.external
blob3fcb0e105b56b43d48e7c0c81757b4111edf9695
1 #!/bin/sh
3 # Eventscript for CTDB to cope with externally managed public IP addresses
5 # If DisableIPFailover is set:
7 # * 10.interface must be disabled.
8 # * For connection tracking/killing to work this script must be enabled.
10 [ -n "$CTDB_BASE" ] || \
11 export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
13 . $CTDB_BASE/functions
14 loadconfig
16 if [ -z "$CTDB_PUBLIC_ADDRESSES" ] ; then
17 exit 0
20 if [ ! -f "$CTDB_PUBLIC_ADDRESSES" ] ; then
21 if [ "$1" = "init" ]; then
22 echo "No public addresses file found. Nothing to do for 10.interfaces.external"
24 exit 0
27 takeover_assigned_ips ()
29 ctdb_get_pnn
31 ctdb -X ip |
32 awk -F'|' '{print $2}' |
33 while read ip ; do
34 if [ -n "$(ip_maskbits_iface $ip)" ] ; then
35 echo "Assigning $ip to this node ($pnn)"
36 ctdb moveip "$ip" "$pnn"
38 done
41 ctdb_check_args "$@"
43 case "$1" in
44 startup)
45 takeover_assigned_ips
47 esac
49 exit 0