1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-26 18:50:30 +03:00

Eventscripts: 10.interfaces - new function get_all_interfaces().

Move existing interface listing code to new function in preparation
for using it in startup event.

While we're here change the "sort | uniq" into "sort -u" and save some
complexity.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit cd1442531ad079b11c60f46ee9d34f5104bef219)
This commit is contained in:
Martin Schwenke 2011-07-05 17:18:30 +10:00
parent 9bdcdb76be
commit e7963d8a65

View File

@ -28,21 +28,27 @@ mark_down ()
ctdb setifacelink $1 down >/dev/null 2>&1
}
# 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 "s/^[^\t ]*[\t ]*//" -e "s/,/ /g" -e "s/[\t ]*$//" $CTDB_PUBLIC_ADDRESSES)
# Add some special interfaces if they're defined
[ "$CTDB_PUBLIC_INTERFACE" ] && all_interfaces="$CTDB_PUBLIC_INTERFACE $all_interfaces"
[ "$CTDB_NATGW_PUBLIC_IFACE" ] && all_interfaces="$CTDB_NATGW_PUBLIC_IFACE $all_interfaces"
# For all but the 1st line, get the 2nd last field with commas
# changes to spaces.
ctdb_ifaces=$(ctdb -Y ip -v | sed -e '1d' -e 's/:[^:]*:$//' -e 's/^.*://' -e 's/,/ /g')
# Add $ctdb_interfaces and uniquify
all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
}
monitor_interfaces()
{
# Get all the interfaces listed in the public_addresses file
all_interfaces=$(sed -e "s/^[^\t ]*[\t ]*//" -e "s/,/ /g" -e "s/[\t ]*$//" $CTDB_PUBLIC_ADDRESSES)
# Add some special interfaces if they're defined
[ "$CTDB_PUBLIC_INTERFACE" ] && all_interfaces="$CTDB_PUBLIC_INTERFACE $all_interfaces"
[ "$CTDB_NATGW_PUBLIC_IFACE" ] && all_interfaces="$CTDB_NATGW_PUBLIC_IFACE $all_interfaces"
# For all but the 1st line, get the 2nd last field with commas
# changes to spaces.
ctdb_ifaces=$(ctdb -Y ip -v | sed -e '1d' -e 's/:[^:]*:$//' -e 's/^.*://' -e 's/,/ /g')
all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort | uniq)
get_all_interfaces
fail=false
up_interfaces_found=false