]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Read optional configuration (delta) file
authorJohannes Truschnigg <johannes@truschnigg.info>
Sun, 20 Mar 2022 15:06:26 +0000 (16:06 +0100)
committerJohannes Truschnigg <johannes@truschnigg.info>
Sun, 20 Mar 2022 15:06:26 +0000 (16:06 +0100)
sqm_lagthrottle.sh

index 3103281462f019840009263e395abbe6e50fd54a..8f976d353bc3149e10e354bbe291b8c21ec40088 100755 (executable)
@@ -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'