From 0a0c3a2fb76fdee1c6d01d32d0e18786e8df29f7 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 15 Mar 2017 23:20:12 -0700 Subject: [PATCH] Copy working temp to final location. Signed-off-by: Dan Schaper --- advanced/Scripts/piholeDebug.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 3ecc3f4b..8649bb90 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -43,16 +43,11 @@ cat << EOM ::: Please read and note any issues, and follow any directions advised during this process. EOM -# Ensure the file exists, create if not, clear if exists. -truncate --size=0 "${DEBUG_LOG}" -chmod 644 ${DEBUG_LOG} -chown "$USER":pihole ${DEBUG_LOG} - source ${VARSFILE} ### Private functions exist here ### log_write() { - printf "%b" "${@}" >&3 + echo "${@}" >&3 } log_echo() { @@ -363,9 +358,9 @@ testChaos(){ log_write "Pi-hole dnsmasq specific records lookups" log_write "Cache Size:" - dig +short chaos txt cachesize.bind >> ${DEBUG_LOG} + log_write $(dig +short chaos txt cachesize.bind) log_write "Upstream Servers:" - dig +short chaos txt servers.bind >> ${DEBUG_LOG} + log_write $(dig +short chaos txt servers.bind) log_write "" } @@ -378,7 +373,7 @@ checkProcesses() { log_write "" log_write "${i}" log_write " processes status:" - systemctl -l status "${i}" >> "${DEBUG_LOG}" + log_write $(systemctl -l status "${i}") done log_write "" } @@ -428,6 +423,14 @@ dumpPiHoleLog() { finalWork() { local tricorder echo "::: Finshed debugging!" + + # Ensure the file exists, create if not, clear if exists. + truncate --size=0 "${DEBUG_LOG}" + chmod 644 ${DEBUG_LOG} + chown "$USER":pihole ${DEBUG_LOG} + # copy working temp file to final log location + cp /proc/$$/fd/3 "$DEBUG_LOG" + 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..."