ctdb-scripts: Use "git config" as last resort to parse nfs.conf
authorMartin Schwenke <martin@meltin.net>
Thu, 21 Jul 2022 04:22:25 +0000 (14:22 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 22 Jul 2022 16:09:31 +0000 (16:09 +0000)
Some versions of nfs-utils (e.g. recent CentOS 7) use /etc/nfs.conf
but do not include the nfsconf utility to extract values from the
file.  However, git has an excellent conf file parser, so use it as a
last resort.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/statd-callout

index 83fb92eccf006ac979176d15ef51b7f5767d0ed4..38c155e4793068226488ba07ac8e526c88db3d71 100755 (executable)
@@ -32,8 +32,13 @@ die ()
 load_system_config "nfs" "nfs-common"
 
 # If NFS_HOSTNAME not set then try to pull it out of /etc/nfs.conf
-if [ -z "$NFS_HOSTNAME" ] && type nfsconf >/dev/null 2>&1 ; then
-       NFS_HOSTNAME=$(nfsconf --get statd name)
+if [ -z "$NFS_HOSTNAME" ]; then
+       if type nfsconf >/dev/null 2>&1; then
+               NFS_HOSTNAME=$(nfsconf --get statd name)
+       elif type git >/dev/null 2>&1; then
+               # git to the rescue!
+               NFS_HOSTNAME=$(git config --file=/etc/nfs.conf statd.name)
+       fi
 fi
 
 [ -n "$NFS_HOSTNAME" ] || \