]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-scripts: Use nfsconf as a last resort to set NFS_HOSTNAME
authorMartin Schwenke <martin@meltin.net>
Mon, 13 Jul 2020 00:16:33 +0000 (10:16 +1000)
committerKarolin Seeger <kseeger@samba.org>
Thu, 6 Aug 2020 13:32:39 +0000 (13:32 +0000)
If nfsconf exists then use it as last resort to attempt to extract
[statd]:name from /etc/nfs.conf.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14444
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 334dd8cedda6a341e3b89c9adc8102ea5480e452)

ctdb/config/statd-callout

index b75135bbde5e31014082ad7887a085b08e79de2a..67ed2a5bc62154490fdb05acf36e95c39aeee40d 100755 (executable)
@@ -3,10 +3,18 @@
 # This must run as root as CTDB tool commands need to access CTDB socket
 [ "$(id -u)" -eq 0 ] || exec sudo "$0" "$@"
 
-# this script needs to be installed so that statd points to it with the -H 
-# command line argument. The easiest way to do that is to put something like this in 
-# /etc/sysconfig/nfs:
-#   STATD_HOSTNAME="myhostname -H /etc/ctdb/statd-callout"
+# statd must be configured to use this script as its high availability call-out.
+#
+# In most Linux versions this can be done using something like the following...
+#
+# /etc/sysconfig/nfs (Red Hat) or /etc/default/nfs-common (Debian):
+#   NFS_HOSTNAME=myhostname
+#   STATD_HOSTNAME="${NFS_HOSTNAME} -H /etc/ctdb/statd-callout"
+#
+# Newer Red Hat Linux variants instead use /etc/nfs.conf:
+#   [statd]
+#     name = myhostname
+#     ha-callout = /etc/ctdb/statd-callout
 
 [ -n "$CTDB_BASE" ] || \
     CTDB_BASE=$(d=$(dirname "$0") ; cd -P "$d" ; echo "$PWD")
@@ -23,6 +31,11 @@ die ()
 # Try different variables to find config file for NFS_HOSTNAME
 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)
+fi
+
 [ -n "$NFS_HOSTNAME" ] || \
     die "NFS_HOSTNAME is not configured. statd-callout failed"