Ignore commented lines when reding PRIVACYLEVEL from config file

Create dedicated getVal function in utils.sh as it might be useful somewhere else
Account for tailing comments and $key not being on the first line

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König 2023-02-16 15:21:18 +01:00
parent 45cab12392
commit 4fd0f15d90
No known key found for this signature in database
3 changed files with 38 additions and 3 deletions

View file

@ -2612,7 +2612,8 @@ main() {
# Get the privacy level if it exists (default is 0)
if [[ -f "${FTL_CONFIG_FILE}" ]]; then
PRIVACY_LEVEL=$(sed -ne 's/PRIVACYLEVEL=\(.*\)/\1/p' "${FTL_CONFIG_FILE}")
# use getVal from utils.sh to get PRIVACYLEVEL
PRIVACY_LEVEL=$(getVal "${FTL_CONFIG_FILE}" "PRIVACYLEVEL")
# If no setting was found, default to 0
PRIVACY_LEVEL="${PRIVACY_LEVEL:-0}"