From 49bb6dc0daf107710ce1844c427ea0303fd307ef Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 20 Feb 2025 18:25:35 +0100 Subject: [PATCH 1/2] Apply chosen upstream DNS on fresh install While the dialog is shown to choose or enter an upstream DNS for Pi-hole, it is never applied. Hence fresh Pi-hole installs have no upstream DNS and cannot resolve queries. It is now checked for the two generated variables PIHOLE_DNS_1 and PIHOLE_DNS_2, a TOML array generated and applied via pihole-FTL CLI. Signed-off-by: MichaIng --- automated install/basic-install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a5c5f3e2..d45b6c00 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -2549,9 +2549,14 @@ main() { restart_service pihole-FTL - # write privacy level and logging to pihole.toml + # apply settings to pihole.toml # needs to be done after FTL service has been started, otherwise pihole.toml does not exist - # set on fresh installations by setPrivacyLevel() and setLogging( + # set on fresh installations by setDNS() and setPrivacyLevel() and setLogging() + if [ -n "${PIHOLE_DNS_1}" ]; then + local string="\"${PIHOLE_DNS_1}\"" + [ -n "${PIHOLE_DNS_2}" ] && string+=", \"${PIHOLE_DNS_2}\"" + setFTLConfigValue "dns.upstreams" "[ $string ]" + fi if [ -n "${QUERY_LOGGING}" ]; then setFTLConfigValue "dns.queryLogging" "${QUERY_LOGGING}" fi From cd4efc3141325b1ac78fcb0b36ddd1c14661bdf8 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 20 Feb 2025 18:05:00 +0100 Subject: [PATCH 2/2] Fix empty password detection The CLI skips double quotes in config output, hence the output is completely empty, if no password was applied yet, e.g. on a fresh install. This leads to an unprotected web interface. The check is corrected, to have a random password applied as intended. Additionally, the logic to show an unchanged or unset password on the completion dialog is inverted to correctly show "unchanged" resp. "NOT SET" if the password has not been changed resp. is empty. Signed-off-by: MichaIng --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index d45b6c00..3bf14cc5 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1766,7 +1766,7 @@ displayFinalMessage() { if [[ "${#1}" -gt 0 ]]; then # set the password to the first argument. pwstring="$1" - elif [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then + elif [[ -n $(pihole-FTL --config webserver.api.pwhash) ]]; then # Else if the password exists from previous setup, we'll load it later pwstring="unchanged" else @@ -2518,7 +2518,7 @@ main() { # Add password to web UI if there is none pw="" # If no password is set, - if [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then + if [[ -z $(pihole-FTL --config webserver.api.pwhash) ]]; then # generate a random password pw=$(tr -dc _A-Z-a-z-0-9