summaryrefslogtreecommitdiff
path: root/ctdb/tools/onnode
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2010-01-21 13:40:03 +1100
committerMartin Schwenke <martin@meltin.net>2010-01-21 13:40:03 +1100
commit9660f9c887a27fb0fca05c5ef6e533c1e52e1e65 (patch)
tree6e09dbc9cac81293e7a860818ce3b707076eab79 /ctdb/tools/onnode
parent14b3c37d9ddf3387bb30e68bd8b1ba08c789070e (diff)
downloadsamba-9660f9c887a27fb0fca05c5ef6e533c1e52e1e65.tar.gz
onnode: update algorithm for finding nodes file.
2 changes: * If a relative nodes file is specified via -f or $CTDB_NODES_FILE but this file does not exist then try looking for the file in /etc/ctdb (or $CTDB_BASE if set). * If a nodes file is specified via -f or $CTDB_NODES_FILE but this file does not exist (even when checked as per above) then do not fall back to /etc/ctdb/nodes ((or $CTDB_BASE if set). The old behaviour was surprising and hid errors. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 6b5a5bb62369284585057caf09f05d2d5e3b9927)
Diffstat (limited to 'ctdb/tools/onnode')
-rwxr-xr-xctdb/tools/onnode17
1 files changed, 15 insertions, 2 deletions
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode
index c44b89ad5d2..fa61b47e5bd 100755
--- a/ctdb/tools/onnode
+++ b/ctdb/tools/onnode
@@ -231,8 +231,21 @@ get_nodes ()
if [ -n "$CTDB_NODES_SOCKETS" ] ; then
all_nodes="$CTDB_NODES_SOCKETS"
else
- [ -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)
+ local f="${ctdb_base}/nodes"
+ if [ -n "$CTDB_NODES_FILE" ] ; then
+ f="$CTDB_NODES_FILE"
+ if [ ! -e "$f" -a "${f#/}" = "$f" ] ; then
+ # $f is relative, try in $ctdb_base
+ f="${ctdb_base}/${f}"
+ fi
+ fi
+
+ if [ ! -r "$f" ] ; then
+ echo "${prog}: unable to open nodes file \"${f}\"" >&2
+ exit 1
+ fi
+
+ all_nodes=$(sed -e 's@#.*@@g' -e 's@ *@@g' -e 's@^$@#DEAD@' "$f")
fi
local nodes=""