onnode - respect $CTDB_BASE rather than hard-coding /etc/ctdb.
authorMartin Schwenke <martin@meltin.net>
Thu, 21 Jan 2010 02:16:18 +0000 (13:16 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 21 Jan 2010 07:52:31 +0000 (18:52 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
tools/onnode

index 7c0a86eb9d1ab4548a0f21a6fd24526ffefc6ef2..c44b89ad5d29e3b6393f41a4803cfa32656fad9a 100755 (executable)
@@ -63,6 +63,8 @@ quiet=false
 prefix=""
 names_ok=false
 
+ctdb_base="${CTDB_BASE:-/etc/ctdb}"
+
 parse_options ()
 {
     # $POSIXLY_CORRECT means that the command passed to onnode can
@@ -165,7 +167,7 @@ get_nodes_with_status ()
            # Succeeded.  Get address.  NOTE: this is an optimisation.
            # It might be better to get the node number and then get
            # the nth node to get the address.  This would make things
-           # more consistent if /etc/ctdb/nodes actually contained
+           # more consistent if $ctdb_base/nodes actually contained
            # hostnames.
            nodes="${nodes} ${t##*:}"
        fi
@@ -229,7 +231,7 @@ get_nodes ()
     if [ -n "$CTDB_NODES_SOCKETS" ] ; then 
        all_nodes="$CTDB_NODES_SOCKETS"
     else
-       [ -e "$CTDB_NODES_FILE" ] || CTDB_NODES_FILE=/etc/ctdb/nodes
+       [ -e "$CTDB_NODES_FILE" ] || CTDB_NODES_FILE="${ctdb_base}/nodes"
        all_nodes=$(sed -e 's@#.*@@g' -e 's@ *@@g' -e 's@^$@#DEAD@' $CTDB_NODES_FILE)
     fi
 
@@ -305,7 +307,7 @@ if [ -n "$CTDB_NODES_SOCKETS" ] ; then
     SSH=fakessh
 else 
     # Could "2>/dev/null || true" but want to see errors from typos in file.
-    [ -r /etc/ctdb/onnode.conf ] && . /etc/ctdb/onnode.conf
+    [ -r "${ctdb_base}/onnode.conf" ] && . "${ctdb_base}/onnode.conf"
     [ -n "$SSH" ] || SSH=ssh
     if [ "$SSH" = "ssh" ] ; then
        ssh_opts="-n"