From 0489e57d1045e0171b325ea9ebf11ad785158602 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 16 Oct 2023 17:11:11 +0100 Subject: [PATCH] Add special handling for FTL Config names that have underscores in them Signed-off-by: Adam Warner --- src/bash_functions.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/bash_functions.sh b/src/bash_functions.sh index 1911bea..4c0e480 100644 --- a/src/bash_functions.sh +++ b/src/bash_functions.sh @@ -127,11 +127,33 @@ apply_FTL_Configs_From_Env(){ # Replace underscores with dots in the name to match pihole-FTL expectiations name="${name//_/.}" - # Special handing for the value if the name is dns.upstreams - if [ "$name" == "dns.upstreams" ]; then - value='["'${value//;/\",\"}'"]' - fi + # Special handling for some FTL Config values + case "$name" in + # Convert the semicolon separated list to a JSON array + "dns.upstreams") + value='["'${value//;/\",\"}'"]' + ;; + # The following config names have an underscore in them, + # so we need to re-convert the dot back to an underscore + "webserver.tls.rev.proxy") + name="webserver.tls.rev_proxy" + ;; + "webserver.api.totp.secret") + name="webserver.api.totp_secret" + ;; + "webserver.api.allow.destructive") + name="webserver.api.allow_destructive" + ;; + "misc.delay.startup") + name="misc.delay_startup" + ;; + "misc.dnsmasq.lines") + name="misc.dnsmasq_lines" + ;; + esac + + # Mask the value if it is a password, else display the value as is if [ "$name" == "webserver.api.password" ]; then masked_value=$(printf "%${#value}s" | tr " " "*") else