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>
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=""