diff options
author | Martin Schwenke <martin@meltin.net> | 2011-07-05 17:18:30 +1000 |
---|---|---|
committer | Martin Schwenke <martin@meltin.net> | 2011-08-12 16:34:34 +1000 |
commit | e7963d8a65a699689dfc4540110ca2892f18ab1f (patch) | |
tree | e36f625582be01235032ebe4d3396a90b135d126 | |
parent | 9bdcdb76be52cf0285fcfb72da93d10fc24d8f16 (diff) | |
download | samba-e7963d8a65a699689dfc4540110ca2892f18ab1f.tar.gz samba-e7963d8a65a699689dfc4540110ca2892f18ab1f.tar.xz samba-e7963d8a65a699689dfc4540110ca2892f18ab1f.zip |
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)
-rwxr-xr-x | ctdb/config/events.d/10.interface | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface index 4e33aa48c3..cad5bf85fe 100755 --- a/ctdb/config/events.d/10.interface +++ b/ctdb/config/events.d/10.interface @@ -28,21 +28,27 @@ mark_down () ctdb setifacelink $1 down >/dev/null 2>&1 } -monitor_interfaces() +# 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) + # 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" + # 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') - # 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) +} - all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort | uniq) +monitor_interfaces() +{ + get_all_interfaces fail=false up_interfaces_found=false |