ctdb-tests: Factor out function config_from_environment()
authorMartin Schwenke <martin@meltin.net>
Mon, 29 Aug 2016 06:05:33 +0000 (16:05 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 1 Sep 2016 11:30:10 +0000 (13:30 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12180

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/simple/scripts/local_daemons.bash

index ecb64f9260bd9a0d7dbac1af617c48ce61b024da..022bbf8880a088db151189e3b0d96514e3ccdae1 100644 (file)
@@ -22,6 +22,15 @@ export CTDB_NODES="${TEST_VAR_DIR}/nodes.txt"
 
 #######################################
 
+config_from_environment ()
+{
+       # Override from the environment.  This would be easier if env was
+       # guaranteed to quote its output so it could be reused.
+       env |
+       grep '^CTDB_' |
+       sed -e 's@=\([^"]\)@="\1@' -e 's@[^"]$@&"@' -e 's@="$@&"@'
+}
+
 setup_ctdb ()
 {
     mkdir -p "${TEST_VAR_DIR}/test.db/persistent"
@@ -99,11 +108,9 @@ CTDB_SOCKET="${TEST_VAR_DIR}/sock.$pnn"
 CTDB_NOSETSCHED=yes
 EOF
 
-       # Override from the environment.  This would be easier if env was
-       # guaranteed to quote its output so it could be reused.
-       env |
-       grep '^CTDB_' |
-       sed -e 's@=\([^"]\)@="\1@' -e 's@[^"]$@&"@' -e 's@="$@&"@' >>"$conf"
+       # Append any configuration variables set in environment to
+       # configuration file so they affect CTDB after each restart.
+       config_from_environment >>"$conf"
     done
 }