From f9392cccb17804ddecbdc19d4cbdac3cafaa6431 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 20 Mar 2022 16:06:26 +0100 Subject: [PATCH] Read optional configuration (delta) file --- sqm_lagthrottle.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sqm_lagthrottle.sh b/sqm_lagthrottle.sh index 3103281..8f976d3 100755 --- a/sqm_lagthrottle.sh +++ b/sqm_lagthrottle.sh @@ -55,6 +55,7 @@ PING_GW_IPV6=no # do not use - broken TZ=UTC LC_ALL=C export TZ LC_ALL +SQML_CFGFILE=./sqm_lagthrottle.conf __is_num() { @@ -104,6 +105,20 @@ do done +if [ -r "${SQML_CFGFILE}" ] && sh -n "${SQML_CFGFILE}" +then + printf 'Evaluating configuration delta from file "%s"...\n' "${SQML_CFGFILE}" + eval "set -x; $(grep -E '[A-Z][A-Z_]+=' "${SQML_CFGFILE}"); set +x" + _cfg_ok=$? + set +x + if [ ${_cfg_ok} -ne 0 ] + then + printf 'FATAL: Configuration delta in "%s" could not be evaluated without errors."\n' + exit 1 + fi +fi + + if ! test -r ./__sqm_lagthrottle.awk then printf 'FATAL: "__sqm_lagthrottle.awk" not found; are you in the correct directory?"\n' -- 2.39.5