From de102fde5c2007d9c6ca649394a62cea8b9558f7 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 22 Jan 2017 20:38:09 +0000 Subject: [PATCH 1/4] Add line count and size check for pihole.log --- advanced/Scripts/piholeDebug.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 09d9a786..c961f103 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -365,6 +365,17 @@ header_write "Analyzing gravity.list" && log_write "${GRAVITYFILE} is ${gravity_length} lines long." \ || log_echo "Warning: No gravity.list file found!" +header_write "Analyzing pihole.log" + + pihole_length=$(wc -l "${PIHOLELOG}") \ + && log_write "${PIHOLELOG} is ${pihole_length} lines long." \ + || log_echo "Warning: No pihole.log file found!" + + pihole_size=$(du -h "${PIHOLELOG}") \ + && log_write "${PIHOLELOG} is ${pihole_length}." \ + || log_echo "Warning: No pihole.log file found!" + + # Continuously append the pihole.log file to the pihole_debug.log file dumpPiHoleLog() { trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT From 1ad23a065eca674b530b26542c12095045db9cbc Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 22 Jan 2017 20:38:46 +0000 Subject: [PATCH 2/4] switch out `wc -l` with `grep -c ^` --- advanced/Scripts/piholeDebug.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index c961f103..fae667ce 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -361,13 +361,13 @@ files_check "${ADLISTFILE}" header_write "Analyzing gravity.list" - gravity_length=$(wc -l "${GRAVITYFILE}") \ + gravity_length=$(grep -c ^ "${GRAVITYFILE}") \ && log_write "${GRAVITYFILE} is ${gravity_length} lines long." \ || log_echo "Warning: No gravity.list file found!" header_write "Analyzing pihole.log" - pihole_length=$(wc -l "${PIHOLELOG}") \ + pihole_length=$(grep -c ^ "${PIHOLELOG}") \ && log_write "${PIHOLELOG} is ${pihole_length} lines long." \ || log_echo "Warning: No pihole.log file found!" From 9acc3aac0176d38dc3b8a265c43a21dd7e0ebc2f Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 22 Jan 2017 20:44:07 +0000 Subject: [PATCH 3/4] pipe `du -h` output to awk to ensure we only get the file size, and not the filename too. Yeah that's right Dom, pipe. --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index fae667ce..08f69943 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -371,7 +371,7 @@ header_write "Analyzing pihole.log" && log_write "${PIHOLELOG} is ${pihole_length} lines long." \ || log_echo "Warning: No pihole.log file found!" - pihole_size=$(du -h "${PIHOLELOG}") \ + pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \ && log_write "${PIHOLELOG} is ${pihole_length}." \ || log_echo "Warning: No pihole.log file found!" From fe8c365d1728398f5f2ad604276ae84d48e76245 Mon Sep 17 00:00:00 2001 From: Promofaux Date: Sun, 22 Jan 2017 20:53:30 +0000 Subject: [PATCH 4/4] codacy never lies --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 08f69943..f763d2b8 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -372,7 +372,7 @@ header_write "Analyzing pihole.log" || log_echo "Warning: No pihole.log file found!" pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \ - && log_write "${PIHOLELOG} is ${pihole_length}." \ + && log_write "${PIHOLELOG} is ${pihole_size}." \ || log_echo "Warning: No pihole.log file found!"