From b20ccaa36da23c8ee84b117b2e82e98bd2be4fcc Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Thu, 21 Jul 2022 14:22:25 +1000 Subject: [PATCH] ctdb-scripts: Use "git config" as last resort to parse nfs.conf 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 Reviewed-by: Amitay Isaacs --- ctdb/config/statd-callout | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 83fb92eccf0..38c155e4793 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -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" ] || \ -- 2.47.3