diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index fae7c0b9..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 @@ -407,20 +413,24 @@ 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 + 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 + 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}" - 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." diff --git a/pihole b/pihole index b79ab2b7..41946f35 100755 --- a/pihole +++ b/pihole @@ -45,7 +45,19 @@ wildcardFunc() { } debugFunc() { - "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh + local automated + local web + + # Pull off the `debug` leaving passed call augmentation flags in $1 + shift + if [[ "$@" == *"-a"* ]]; then + automated="true" + fi + if [[ "$@" == *"-w"* ]]; then + web="true" + fi + + AUTOMATED=${automated:-} WEBCALL=${web:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh exit 0 } @@ -278,6 +290,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 @@ -287,15 +301,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 @@ -310,7 +324,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;;