summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-12-19 14:19:32 +1100
committerMichael Adam <obnox@samba.org>2015-01-09 02:03:40 +0100
commit4638010abb116aed0c180207aaa11475277aecb7 (patch)
treef070d74f5a3f6c4c5886415172d570f072bacfe5 /ctdb
parenta5c5eee7d186d938c5b458cb6dbf0c78cb548b63 (diff)
downloadsamba-4638010abb116aed0c180207aaa11475277aecb7.tar.gz
samba-4638010abb116aed0c180207aaa11475277aecb7.tar.xz
samba-4638010abb116aed0c180207aaa11475277aecb7.zip
ctdb-scripts: Don't use the GNU awk gensub() function
This is a gawk extension and can't be used reliably if just running "awk". It is simple enough to switch to using the standard sub() and gsub() functions. The alternative is to switch to explicitly running "gawk". However, although the eventscripts aren't exactly portable, it is probably better to move closer to portability than further away. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/functions7
-rwxr-xr-xctdb/config/statd-callout4
-rwxr-xr-xctdb/tests/complex/18_ctdb_reloadips.sh2
-rw-r--r--ctdb/tests/scripts/integration.bash5
4 files changed, 11 insertions, 7 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions
index df818a0323..3bc9e3d29e 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -915,7 +915,7 @@ delete_ip_from_iface()
}
}
-# If the given IP is hosted then print 2 items: maskbits and iface
+# If the given IP is hosted then print 2 items: maskbits and iface
ip_maskbits_iface ()
{
_addr="$1"
@@ -927,8 +927,9 @@ ip_maskbits_iface ()
ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
awk -v family="${_family}" \
- 'NR == 1 { iface = gensub(":$", "", 1, $2) } \
- $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+ 'NR == 1 { iface = $2; sub(":$", "", iface) } \
+ $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
+ print mask, iface, family }'
}
drop_ip ()
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 5e8eb0e789..e2a955eab5 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -145,7 +145,9 @@ case "$1" in
# server-IP client-IP
# but only for the server-IPs that are hosted on this node.
sed_expr=$(ctdb ip | tail -n +2 |
- awk -v pnn=$pnn 'pnn == $2 { printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", gensub(/\./, "\\\\.", "g", $1) }')
+ awk -v pnn=$pnn 'pnn == $2 { \
+ ip = $1; gsub(/\./, "\\\\.", ip); \
+ printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')
statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort)
[ -n "$statd_state" ] || exit 0
diff --git a/ctdb/tests/complex/18_ctdb_reloadips.sh b/ctdb/tests/complex/18_ctdb_reloadips.sh
index 13f7c213af..71f997cda5 100755
--- a/ctdb/tests/complex/18_ctdb_reloadips.sh
+++ b/ctdb/tests/complex/18_ctdb_reloadips.sh
@@ -56,7 +56,7 @@ ctdb_ip_info=$(echo "$out" | awk -F'|' 'NR > 1 { print $2, $3, $5 }')
echo "Getting IP information from interfaces..."
try_command_on_node all "ip addr show"
ip_addr_info=$(echo "$out" | \
- awk '$1 == "inet" { print gensub(/\/.*/, "", "", $2)}')
+ awk '$1 == "inet" { ip = $2; sub(/\/.*/, "", ip); print ip }')
prefix=""
for b in $(seq 0 255) ; do
diff --git a/ctdb/tests/scripts/integration.bash b/ctdb/tests/scripts/integration.bash
index 0d27c93643..139a9a23cb 100644
--- a/ctdb/tests/scripts/integration.bash
+++ b/ctdb/tests/scripts/integration.bash
@@ -699,8 +699,9 @@ ip_maskbits_iface ()
ip addr show to "${_addr}/${_bits}" 2>/dev/null | \
awk -v family="${_family}" \
- 'NR == 1 { iface = gensub(":$", "", 1, $2) } \
- $1 ~ /inet/ { print gensub(".*/", "", 1, $2), iface, family }'
+ 'NR == 1 { iface = $2; sub(":$", "", iface) } \
+ $1 ~ /inet/ { mask = $2; sub(".*/", "", mask); \
+ print mask, iface, family }'
}
drop_ip ()