From c2903241859d6794a377d2a1d5dd4d94d4421f03 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Tue, 16 Oct 2018 19:55:52 -0500 Subject: [PATCH] Change password logic completely to avoid any extra debug prints Signed-off-by: Adam Hill --- README.md | 2 +- bash_functions.sh | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9dfc3a9..0dbc189 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ docker run -d \ pihole/pihole:latest echo -n "Your password for https://${IP}/admin/ is " -docker logs pihole 2> /dev/null | grep 'password:' +docker logs pihole 2> /dev/null | grep 'password' ``` **This is just an example and might need changing.** Volumes are stored in the directory `$DOCKER_CONFIGS` and are recommended for persisting data across docker re-creations for updating images. As mentioned on line 2, the auto `IP_LOOKUP` variable may not work for VPN tunnel interfaces. diff --git a/bash_functions.sh b/bash_functions.sh index cdd5a95..43fc397 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -242,16 +242,21 @@ generate_password() { setup_web_password() { PASS="$1" # Turn bash debug on while setting up password (to print it) - set -x if [[ "$PASS" == "" ]] ; then echo "" | pihole -a -p else + echo "Setting password: ${PASS}" + set -x pihole -a -p "$PASS" "$PASS" fi - if [ "${PH_VERBOSE:-0}" -lt 1 ] ; then - # Turn bash debug back off after print password setup - # (subshell to null hides printing output) - { set +x; } 2>/dev/null + # Turn bash debug back off after print password setup + # (subshell to null hides printing output) + { set +x; } 2>/dev/null + + # To avoid printing this if conditional in bash debug, turn off debug above.. + # then re-enable debug if necessary (more code but cleaner printed output) + if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then + set -x fi }