1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-01-22 05:51:15 +00:00

Merge pull request #1281 from pi-hole/tweak/web_debug

Back end changes for Web based debug calls.
This commit is contained in:
Dan Schaper 2017-02-27 12:21:33 -08:00 committed by GitHub
commit f6fc6a5e56
2 changed files with 43 additions and 19 deletions

View File

@ -332,11 +332,17 @@ debugLighttpd() {
} }
countdown() { countdown() {
local tuvix
tuvix=${TIMEOUT} 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 ] while [ $tuvix -ge 1 ]
do 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 sleep 5
tuvix=$(( tuvix - 5 )) tuvix=$(( tuvix - 5 ))
done done
@ -407,20 +413,24 @@ finalWork() {
local tricorder local tricorder
echo "::: Finshed debugging!" echo "::: Finshed debugging!"
echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only." 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 if [[ "${AUTOMATED}" ]]; then
case ${response} in echo "::: Debug script running in automated mode, uploading log to tricorder..."
[yY][eE][sS]|[yY]) tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999)
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
echo "::: Log will NOT be uploaded to tricorder." [yY][eE][sS]|[yY])
;; tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999)
esac ;;
*)
echo "::: Log will NOT be uploaded to tricorder."
;;
esac
fi
# Check if tricorder.pi-hole.net is reachable and provide token. # Check if tricorder.pi-hole.net is reachable and provide token.
if [ -n "${tricorder}" ]; then if [ -n "${tricorder}" ]; then
echo "::: Your debug token is : ${tricorder}" echo "::: ---=== Your debug token is : ${tricorder} Please make a note of it. ===---"
echo "::: Please contact the Pi-hole team with your token for assistance." echo "::: Contact the Pi-hole team with your token for assistance."
echo "::: Thank you." echo "::: Thank you."
else else
echo "::: There was an error uploading your debug log." echo "::: There was an error uploading your debug log."

24
pihole
View File

@ -45,7 +45,19 @@ wildcardFunc() {
} }
debugFunc() { 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 exit 0
} }
@ -278,6 +290,8 @@ helpFunc() {
::: -b, blacklist Blacklist domain(s) (exact match) ::: -b, blacklist Blacklist domain(s) (exact match)
::: -wild, wildcard Blacklist whole domain(s) (wildcard) ::: -wild, wildcard Blacklist whole domain(s) (wildcard)
::: -d, debug Start a debugging session ::: -d, debug Start a debugging session
::: Automated debugging can be enabled with `-a`.
::: 'pihole -d -a'
::: -f, flush Flush the 'pihole.log' file ::: -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 ::: -t, tail Output the last lines of the 'pihole.log' file. Lines are appended as the file grows
::: -up, updatePihole Update Pi-hole components ::: -up, updatePihole Update Pi-hole components
@ -287,15 +301,15 @@ helpFunc() {
::: -h, help Show this help dialog ::: -h, help Show this help dialog
::: -v, version Show installed versions of Pi-Hole and Web-Admin ::: -v, version Show installed versions of Pi-Hole and Web-Admin
::: -q, query Query the adlists for a specific domain ::: -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') ::: -l, logging Enable or Disable logging (pass 'on' or 'off')
::: -a, admin Admin webpage options ::: -a, admin Admin webpage options
::: uninstall Uninstall Pi-Hole from your system :(! ::: uninstall Uninstall Pi-Hole from your system :(!
::: status Is Pi-Hole Enabled or Disabled ::: status Is Pi-Hole Enabled or Disabled
::: enable Enable Pi-Hole DNS Blocking ::: enable Enable Pi-Hole DNS Blocking
::: disable Disable Pi-Hole DNS Blocking ::: disable Disable Pi-Hole DNS Blocking
::: Blocking can also be disabled only temporarily, e.g., ::: Blocking can also be disabled only temporarily, e.g.,
::: 'pihole disable 5m' - will disable blocking for 5 minutes ::: 'pihole disable 5m' - will disable blocking for 5 minutes
::: restartdns Restart dnsmasq ::: restartdns Restart dnsmasq
EOM EOM
exit 0 exit 0
@ -310,7 +324,7 @@ case "${1}" in
"-w" | "whitelist" ) whitelistFunc "$@";; "-w" | "whitelist" ) whitelistFunc "$@";;
"-b" | "blacklist" ) blacklistFunc "$@";; "-b" | "blacklist" ) blacklistFunc "$@";;
"-wild" | "wildcard" ) wildcardFunc "$@";; "-wild" | "wildcard" ) wildcardFunc "$@";;
"-d" | "debug" ) debugFunc;; "-d" | "debug" ) debugFunc "$@";;
"-f" | "flush" ) flushFunc;; "-f" | "flush" ) flushFunc;;
"-up" | "updatePihole" ) updatePiholeFunc;; "-up" | "updatePihole" ) updatePiholeFunc;;
"-r" | "reconfigure" ) reconfigurePiholeFunc;; "-r" | "reconfigure" ) reconfigurePiholeFunc;;