ctdb-scripts: Allow load_system_config() to take multiple alternatives
authorMartin Schwenke <martin@meltin.net>
Wed, 20 Mar 2019 10:19:49 +0000 (21:19 +1100)
committerMartin Schwenke <martins@samba.org>
Sun, 31 Mar 2019 10:45:20 +0000 (10:45 +0000)
The situation for NFS config has got more complicated and is probably
broken in statd-callout on Debian-like systems at the moment.  Allow
several alternative configuration names to be tried.  Stop after the
first that is found and loaded.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13860

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@samba.org>
ctdb/config/functions

index 7a47c9d8e79167fde6f15faf21f0e97d1376fce2..1dc165328902ac583000d2c6b1b2aea4def8c958 100755 (executable)
@@ -33,15 +33,16 @@ fi
 
 load_system_config ()
 {
-       if [ -z "$1" ] ; then
-               return
-       fi
-
-       if [ -f "${CTDB_SYS_ETCDIR}/sysconfig/$1" ]; then
-               . "${CTDB_SYS_ETCDIR}/sysconfig/$1"
-       elif [ -f "${CTDB_SYS_ETCDIR}/default/$1" ]; then
-               . "${CTDB_SYS_ETCDIR}/default/$1"
-       fi
+       for _i ; do
+
+               if [ -f "${CTDB_SYS_ETCDIR}/sysconfig/${_i}" ]; then
+                       . "${CTDB_SYS_ETCDIR}/sysconfig/${_i}"
+                       return
+               elif [ -f "${CTDB_SYS_ETCDIR}/default/${_i}" ]; then
+                       . "${CTDB_SYS_ETCDIR}/default/${_i}"
+                       return
+               fi
+       done
 }
 
 # load_script_options [ component script ]