mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
ctdb-scripts: Rename and relocate function get_all_interfaces()
get_all_interfaces() functions gets all names for all public interfaces. However name is misleading. Thus renamed it to get_public_ifaces() and moved it under functions. Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
ff3b92ffae
commit
56eeb058d2
@ -12,37 +12,16 @@
|
||||
|
||||
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
|
||||
@ -50,7 +29,10 @@ monitor_interfaces()
|
||||
# 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
|
||||
|
@ -651,6 +651,30 @@ drop_ip()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user