ctdb-scripts: debug_locks.sh should use configuration to find TDB location
authorMartin Schwenke <martin@meltin.net>
Mon, 4 Nov 2013 01:56:39 +0000 (12:56 +1100)
committerMichael Adam <obnox@samba.org>
Wed, 27 Nov 2013 17:46:16 +0000 (18:46 +0100)
That is, don't use fixed paths.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
ctdb/config/debug_locks.sh [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 0dde861..ce80835
@@ -7,9 +7,17 @@
 # This script can be used only if Samba is configured to use fcntl locks
 # rather than mutex locks.
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
+
+. "$CTDB_BASE/functions"
+
+loadconfig ctdb
+
 # Create sed expression to convert inodes to names
-sed_cmd=$( ls -li /var/ctdb/*.tdb.* /var/ctdb/persistent/*.tdb.* |
-          sed -e "s#/var/ctdb[/persistent]*/\(.*\)#\1#" |
+sed_cmd=$( ls -li "$CTDB_DBDIR"/*.tdb.* "$CTDB_DBDIR_PERSISTENT"/*.tdb.* |
+          sed -e "s#${CTDB_DBDIR}/\(.*\)#\1#" \
+              -e "s#${CTDB_DBDIR_PERSISTENT}/\(.*\)#\1#" |
           awk '{printf "s#[0-9]*:[0-9]*:%s #%s #\n", $1, $10}' )
 
 # Parse /proc/locks and extract following information