From: Martin Schwenke Date: Mon, 23 May 2011 05:33:12 +0000 (+1000) Subject: onnode: fix natgwlist nodespec X-Git-Tag: ctdb-1.2.40~95 X-Git-Url: http://git.samba.org/?p=ctdb.git;a=commitdiff_plain;h=bfffe067a8152145ef54482dccb49529c6a4827f 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 --- diff --git a/tools/onnode b/tools/onnode index 59f2535d..804ab09c 100755 --- a/tools/onnode +++ b/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