From ba5bbf3523a0d9bb490462cf35189d14281c2688 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 26 Feb 2017 15:36:53 -0800 Subject: [PATCH 1/7] Modify `pihole` for `-d -a` arguments. --- pihole | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index b79ab2b7..ad021740 100755 --- a/pihole +++ b/pihole @@ -45,7 +45,12 @@ wildcardFunc() { } debugFunc() { - "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh + local automated + shift + if [[ "${1}" == "-a" ]]; then + automated="true" + fi + AUTOMATED=${automated:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh exit 0 } @@ -310,7 +315,7 @@ case "${1}" in "-w" | "whitelist" ) whitelistFunc "$@";; "-b" | "blacklist" ) blacklistFunc "$@";; "-wild" | "wildcard" ) wildcardFunc "$@";; - "-d" | "debug" ) debugFunc;; + "-d" | "debug" ) debugFunc "$@";; "-f" | "flush" ) flushFunc;; "-up" | "updatePihole" ) updatePiholeFunc;; "-r" | "reconfigure" ) reconfigurePiholeFunc;; From 9b060aab34c87193f837b206dfcd97db40917c17 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 26 Feb 2017 18:22:06 -0800 Subject: [PATCH 2/7] Debug auto mode engaged Signed-off-by: Dan Schaper --- advanced/Scripts/piholeDebug.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index fae7c0b9..dc70a907 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -407,16 +407,19 @@ finalWork() { local tricorder echo "::: Finshed debugging!" echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only." - read -r -p "::: Would you like to upload the log? [y/N] " response - case ${response} in - [yY][eE][sS]|[yY]) - tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999) - ;; - *) - echo "::: Log will NOT be uploaded to tricorder." - ;; - esac - + if [[ "${AUTOMATED}" ]]; then + tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999) + else + read -r -p "::: Would you like to upload the log? [y/N] " response + case ${response} in + [yY][eE][sS]|[yY]) + tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999) + ;; + *) + echo "::: Log will NOT be uploaded to tricorder." + ;; + esac + fi # Check if tricorder.pi-hole.net is reachable and provide token. if [ -n "${tricorder}" ]; then echo "::: Your debug token is : ${tricorder}" From 7244d44a1df4eb9ac8193f581eedd0543eddfce1 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 27 Feb 2017 10:02:00 -0800 Subject: [PATCH 3/7] Notify user that log is being uploaded. Signed-off-by: Dan Schaper --- advanced/Scripts/piholeDebug.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index dc70a907..3131078e 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -408,6 +408,7 @@ finalWork() { echo "::: Finshed debugging!" echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only." if [[ "${AUTOMATED}" ]]; then + echo "Debug script running in automated mode, uploading log to tricorder..." tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999) else read -r -p "::: Would you like to upload the log? [y/N] " response From 6c130b7960918c09a7f1d22ed75911301835bd1d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 27 Feb 2017 10:27:11 -0800 Subject: [PATCH 4/7] Vebiage and highligh the token, also `:::` Signed-off-by: Dan Schaper --- advanced/Scripts/piholeDebug.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 3131078e..176a3ead 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -408,7 +408,7 @@ finalWork() { echo "::: Finshed debugging!" echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only." if [[ "${AUTOMATED}" ]]; then - echo "Debug script running in automated mode, uploading log to tricorder..." + echo "::: Debug script running in automated mode, uploading log to tricorder..." tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999) else read -r -p "::: Would you like to upload the log? [y/N] " response @@ -423,8 +423,8 @@ finalWork() { fi # Check if tricorder.pi-hole.net is reachable and provide token. if [ -n "${tricorder}" ]; then - echo "::: Your debug token is : ${tricorder}" - echo "::: Please contact the Pi-hole team with your token for assistance." + echo "::: ---=== Your debug token is : ${tricorder} Please make a note of it. ===---" + echo "::: Contact the Pi-hole team with your token for assistance." echo "::: Thank you." else echo "::: There was an error uploading your debug log." From 38961fb31b9c3effe86927468f41e8b4015f53a8 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 27 Feb 2017 10:49:25 -0800 Subject: [PATCH 5/7] Help text clarification and addition of the automated debuggin flag. Signed-off-by: Dan Schaper --- pihole | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pihole b/pihole index ad021740..e4d832a5 100755 --- a/pihole +++ b/pihole @@ -283,6 +283,8 @@ helpFunc() { ::: -b, blacklist Blacklist domain(s) (exact match) ::: -wild, wildcard Blacklist whole domain(s) (wildcard) ::: -d, debug Start a debugging session +::: Automated debugging can be enabled with `-a`. +::: 'pihole -d -a' ::: -f, flush Flush the 'pihole.log' file ::: -t, tail Output the last lines of the 'pihole.log' file. Lines are appended as the file grows ::: -up, updatePihole Update Pi-hole components @@ -292,15 +294,15 @@ helpFunc() { ::: -h, help Show this help dialog ::: -v, version Show installed versions of Pi-Hole and Web-Admin ::: -q, query Query the adlists for a specific domain -::: Use 'pihole -q domain -exact' if you want to see exact matches only +::: 'pihole -q domain -exact' shows exact matches only ::: -l, logging Enable or Disable logging (pass 'on' or 'off') ::: -a, admin Admin webpage options ::: uninstall Uninstall Pi-Hole from your system :(! ::: status Is Pi-Hole Enabled or Disabled ::: enable Enable Pi-Hole DNS Blocking ::: disable Disable Pi-Hole DNS Blocking -::: Blocking can also be disabled only temporarily, e.g., -::: 'pihole disable 5m' - will disable blocking for 5 minutes +::: Blocking can also be disabled only temporarily, e.g., +::: 'pihole disable 5m' - will disable blocking for 5 minutes ::: restartdns Restart dnsmasq EOM exit 0 From 83b0600863d787d005621820ce11dcd69b5cbc83 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 27 Feb 2017 11:03:57 -0800 Subject: [PATCH 6/7] Carriage return or newline based webcalls. Signed-off-by: Dan Schaper --- advanced/Scripts/piholeDebug.sh | 10 ++++++++-- pihole | 9 ++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 176a3ead..70d73379 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -332,11 +332,17 @@ debugLighttpd() { } countdown() { + local tuvix tuvix=${TIMEOUT} - printf "::: Logging will automatically teminate in ${TIMEOUT} seconds\n" + printf "::: Logging will automatically teminate in %s seconds\n" "${TIMEOUT}" while [ $tuvix -ge 1 ] do - printf ":::\t${tuvix} seconds left. \r" + printf ":::\t%s seconds left. " "${tuvix}" + if [[ -z "${WEBCALL}" ]]; then + printf "\r" + else + printf "\n" + fi sleep 5 tuvix=$(( tuvix - 5 )) done diff --git a/pihole b/pihole index e4d832a5..cfe032ff 100755 --- a/pihole +++ b/pihole @@ -46,11 +46,18 @@ wildcardFunc() { debugFunc() { local automated + local web + + # Pull off the `debug` leaving passed call augmentation flags in $1 shift if [[ "${1}" == "-a" ]]; then automated="true" fi - AUTOMATED=${automated:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh + if [[ "${2}" == "-w" ]]; then + web="true" + fi + + AUTOMATED=${automated:-} WEBCALL=${web:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh exit 0 } From 17b0db65156dedc9efa7cd71ac3d8199f593f0a2 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 27 Feb 2017 11:40:20 -0800 Subject: [PATCH 7/7] Fix for calling -w without -a. Signed-off-by: Dan Schaper --- pihole | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pihole b/pihole index cfe032ff..41946f35 100755 --- a/pihole +++ b/pihole @@ -50,10 +50,10 @@ debugFunc() { # Pull off the `debug` leaving passed call augmentation flags in $1 shift - if [[ "${1}" == "-a" ]]; then + if [[ "$@" == *"-a"* ]]; then automated="true" fi - if [[ "${2}" == "-w" ]]; then + if [[ "$@" == *"-w"* ]]; then web="true" fi