load_script_options
-ctdb_public_addresses="${CTDB_BASE}/public_addresses"
-
-if [ ! -f "$ctdb_public_addresses" ]; then
+if ! have_public_addresses; then
if [ "$1" = "init" ] ; then
echo "No public addresses file found"
fi
exit 0
fi
-# This sets $all_interfaces as a side-effect.
-get_all_interfaces ()
-{
- # Get all the interfaces listed in the public_addresses file
- all_interfaces=$(sed -e '/^#.*/d' \
- -e 's/^[^\t ]*[\t ]*//' \
- -e 's/,/ /g' \
- -e 's/[\t ]*$//' "$ctdb_public_addresses")
-
- # Get the interfaces for which CTDB has public IPs configured.
- # That is, for all but the 1st line, get the 1st field.
- ctdb_ifaces=$($CTDB -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@')
-
- # Add $ctdb_ifaces and make $all_interfaces unique
- # Use word splitting to squash whitespace
- # shellcheck disable=SC2086
- all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
-}
-
monitor_interfaces()
{
- get_all_interfaces
+ get_public_ifaces
down_interfaces_found=false
up_interfaces_found=false
# Note that this loop must not exit early. It must process
# all interfaces so that the correct state for each interface
# is set in CTDB using setifacelink.
- for _iface in $all_interfaces ; do
+ #
+ # public_ifaces set by get_public_ifaces() above
+ # shellcheck disable=SC2154
+ for _iface in $public_ifaces ; do
if interface_monitor "$_iface" ; then
up_interfaces_found=true
$CTDB setifacelink "$_iface" up >/dev/null 2>&1
fi
}
+have_public_addresses()
+{
+ [ -f "${CTDB_BASE}/public_addresses" ]
+}
+
+# This sets $public_ifaces as a side-effect.
+get_public_ifaces()
+{
+ # Get all the interfaces listed in the public_addresses file
+ public_ifaces=$(sed -e '/^#.*/d' \
+ -e 's/^[^\t ]*[\t ]*//' \
+ -e 's/,/ /g' \
+ -e 's/[\t ]*$//' "${CTDB_BASE}/public_addresses")
+
+ # Get the interfaces for which CTDB has public IPs configured.
+ # That is, for all but the 1st line, get the 1st field.
+ ctdb_ifaces=$($CTDB -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@')
+
+ # Add $ctdb_ifaces and make $public_ifaces unique
+ # Use word splitting to squash whitespace
+ # shellcheck disable=SC2086
+ public_ifaces=$(echo $public_ifaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
+}
+
drop_all_public_ips()
{
# _x is intentionally ignored