diff options
author | Martin Schwenke <martin@meltin.net> | 2011-05-23 15:33:12 +1000 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-06-08 14:24:00 +1000 |
commit | 5ddc10128aaa78d4de85eda4b54f173b4cc88d39 (patch) | |
tree | 6252324646b221979cad6db3efb63ef7e585fc5a /ctdb/tools/onnode | |
parent | 1ef399e48d7370fb7e4870d52f86a0878f35b1e2 (diff) | |
download | samba-5ddc10128aaa78d4de85eda4b54f173b4cc88d39.tar.gz |
onnode: fix natgwlist nodespec
This hasn't worked for a while if ever.
We treat this case specially because the output has 2 works on the 1st
line. We also handle the error case where /etc/ctdb_natgw_nodes
exists but none of the other $NATGW_* configuration is done.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 66e89797c7866d207a5bbf1836f52d70dba7cea6)
Diffstat (limited to 'ctdb/tools/onnode')
-rwxr-xr-x | ctdb/tools/onnode | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode index 59f2535d284..804ab09cc2d 100755 --- a/ctdb/tools/onnode +++ b/ctdb/tools/onnode @@ -189,20 +189,36 @@ get_node_with_property () local prop_node="" if [ "${ctdb_props##:${prop}:}" = "$ctdb_props" ] ; then + # Not in cache. prop_node=$(ctdb "$prop" -Y 2>/dev/null) - # We only want the first line. - local nl=" -" - prop_node="${prop_node%%${nl}*}" if [ $? -eq 0 ] ; then - ctdb_props="${ctdb_props}${ctdb_props:+ }:${prop}:${prop_node}" + if [ "$prop" = "natgwlist" ] ; then + prop_node="${prop_node%% *}" # 1st word + if [ "$prop_node" = "-1" ] ; then + # This works around natgwlist returning 0 even + # when there's no natgw. + prop_node="" + fi + else + # We only want the first line. + local nl=" +" + prop_node="${prop_node%%${nl}*}" + fi else prop_node="" fi + + if [ -n "$prop_node" ] ; then + # Add to cache. + ctdb_props="${ctdb_props}${ctdb_props:+ }:${prop}:${prop_node}" + fi else + # Get from cache. prop_node="${ctdb_props##:${prop}:}" prop_node="${prop_node%% *}" fi + if [ -n "$prop_node" ] ; then echo_nth "$prop_node" $all_nodes else |