1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-02-04 20:30:55 +00:00

Reduce header verbosity. New header writer.

This commit is contained in:
Dan Schaper 2016-10-25 17:19:33 -07:00
parent 4839953328
commit 01f17f9cbb

View File

@ -50,12 +50,16 @@ log_write() {
echo "${1}" >> "${DEBUG_LOG}" echo "${1}" >> "${DEBUG_LOG}"
} }
version_check() { header_write() {
log_write "############################################################" echo "" >> "${DEBUG_LOG}"
log_write "########## Installed Versions ##########" echo "::: ${1}" >> "${DEBUG_LOG}"
log_write "############################################################" echo "" >> "${DEBUG_LOG}"
}
version_check() {
header_write "Installed Package Versions"
echo "::: Detecting Pi-hole installed versions." echo "::: Detecting Pi-hole installed versions."
pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \ pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \
&& log_write "Pi-hole Version: $pi_hole_ver" || log_write "Pi-hole git repository not detected." && log_write "Pi-hole Version: $pi_hole_ver" || log_write "Pi-hole git repository not detected."
admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \ admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \
@ -69,9 +73,7 @@ version_check() {
} }
files_check() { files_check() {
log_write "############################################################" header_write "Files Check"
log_write "########## Files Check ##########"
log_write "############################################################"
#Check existence of setupVars.conf, and source it to get configured network interface for later use in script. #Check existence of setupVars.conf, and source it to get configured network interface for later use in script.
echo -n "::: Detecting existence setupVars.conf..." echo -n "::: Detecting existence setupVars.conf..."
@ -99,9 +101,7 @@ files_check() {
} }
distro_check() { distro_check() {
log_write "############################################################" header_write "Installed OS Distribution"
log_write "######## Installed OS Distribution #########"
log_write "############################################################"
echo "::: Checking installed OS Distribution release." echo "::: Checking installed OS Distribution release."
TMP=$(cat /etc/*release || echo "Failed to find release") TMP=$(cat /etc/*release || echo "Failed to find release")
@ -112,9 +112,7 @@ distro_check() {
} }
ip_check() { ip_check() {
log_write "############################################################" header_write "IP Address Information"
log_write "######## IP Address Information #########"
log_write "############################################################"
echo "::: Writing local IPs to logfile" echo "::: Writing local IPs to logfile"
IPADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')" IPADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')"
@ -176,9 +174,7 @@ ip_check() {
} }
hostnameCheck() { hostnameCheck() {
log_write "############################################################" header_write "Hostname Information"
log_write "######## Hostname Information #########"
log_write "############################################################"
echo "::: Writing locally configured hostnames to logfile" echo "::: Writing locally configured hostnames to logfile"
# Write the hostname output to compare against entries in /etc/hosts, which is logged next # Write the hostname output to compare against entries in /etc/hosts, which is logged next
@ -197,9 +193,7 @@ hostnameCheck() {
} }
portCheck() { portCheck() {
log_write "############################################################" header_write "Open Port Information"
log_write "######## Open Port Information #########"
log_write "############################################################"
echo "::: Detecting local server port 80 and 53 processes." echo "::: Detecting local server port 80 and 53 processes."
@ -209,10 +203,7 @@ portCheck() {
} }
testResolver() { testResolver() {
log_write "############################################################" header_write "Resolver Functions Check"
log_write "############ Resolver Functions Check ############"
log_write "############################################################"
# Find a blocked url that has not been whitelisted. # Find a blocked url that has not been whitelisted.
TESTURL="doubleclick.com" TESTURL="doubleclick.com"
@ -269,10 +260,8 @@ testResolver() {
} }
checkProcesses() { checkProcesses() {
log_write "#######################################" header_write "Processes Check"
log_write "########### Processes Check ###########"
log_write "#######################################"
log_write ":::"
echo "::: Logging status of lighttpd and dnsmasq..." echo "::: Logging status of lighttpd and dnsmasq..."
PROCESSES=( lighttpd dnsmasq ) PROCESSES=( lighttpd dnsmasq )
for i in "${PROCESSES[@]}"; do for i in "${PROCESSES[@]}"; do
@ -285,10 +274,8 @@ checkProcesses() {
} }
debugLighttpd() { debugLighttpd() {
log_write "::: Writing lighttpd to debug log..." header_write "lighttpd.conf"
log_write "#######################################"
log_write "############ lighttpd.conf ############"
log_write "#######################################"
if [ -e "${LIGHTTPDFILE}" ]; then if [ -e "${LIGHTTPDFILE}" ]; then
while read -r line; do while read -r line; do
if [ ! -z "${line}" ]; then if [ ! -z "${line}" ]; then
@ -303,9 +290,10 @@ debugLighttpd() {
fi fi
if [ -e "${LIGHTTPDERRFILE}" ]; then if [ -e "${LIGHTTPDERRFILE}" ]; then
log_write "#######################################" log_write ""
log_write "######### lighttpd error.log ##########" log_write "::: lighttpd error.log"
log_write "#######################################" log_write ""
cat "${LIGHTTPDERRFILE}" >> ${DEBUG_LOG} cat "${LIGHTTPDERRFILE}" >> ${DEBUG_LOG}
else else
log_write "No lighttpd error.log file found!" log_write "No lighttpd error.log file found!"
@ -327,9 +315,7 @@ testResolver
debugLighttpd debugLighttpd
echo "::: Writing dnsmasq.conf to debug log..." echo "::: Writing dnsmasq.conf to debug log..."
log_write "#######################################" header_write "Dnsmasq configuration"
log_write "############### Dnsmasq ###############"
log_write "#######################################"
if [ -e "${DNSMASQFILE}" ]; then if [ -e "${DNSMASQFILE}" ]; then
#cat $DNSMASQFILE >> $DEBUG_LOG #cat $DNSMASQFILE >> $DEBUG_LOG
while read -r line; do while read -r line; do
@ -345,9 +331,8 @@ else
fi fi
echo "::: Writing 01-pihole.conf to debug log..." echo "::: Writing 01-pihole.conf to debug log..."
log_write "#######################################" header_write "01-pihole.conf"
log_write "########### 01-pihole.conf ############"
log_write "#######################################"
if [ -e "${PIHOLECONFFILE}" ]; then if [ -e "${PIHOLECONFFILE}" ]; then
while read -r line; do while read -r line; do
if [ ! -z "${line}" ]; then if [ ! -z "${line}" ]; then
@ -362,9 +347,8 @@ else
fi fi
echo "::: Writing size of gravity.list to debug log..." echo "::: Writing size of gravity.list to debug log..."
log_write "#######################################" header_write "gravity.list"
log_write "############ gravity.list #############"
log_write "#######################################"
if [ -e "${GRAVITYFILE}" ]; then if [ -e "${GRAVITYFILE}" ]; then
wc -l "${GRAVITYFILE}" >> ${DEBUG_LOG} wc -l "${GRAVITYFILE}" >> ${DEBUG_LOG}
log_write "" log_write ""
@ -376,9 +360,7 @@ fi
### Pi-hole application specific logging ### ### Pi-hole application specific logging ###
echo "::: Writing whitelist to debug log..." echo "::: Writing whitelist to debug log..."
log_write "#######################################" header_write "Whitelist"
log_write "############## Whitelist ##############"
log_write "#######################################"
if [ -e "${WHITELISTFILE}" ]; then if [ -e "${WHITELISTFILE}" ]; then
cat "${WHITELISTFILE}" >> ${DEBUG_LOG} cat "${WHITELISTFILE}" >> ${DEBUG_LOG}
log_write log_write
@ -388,9 +370,7 @@ else
fi fi
echo "::: Writing blacklist to debug log..." echo "::: Writing blacklist to debug log..."
log_write "#######################################" header_write "Blacklist"
log_write "############## Blacklist ##############"
log_write "#######################################"
if [ -e "${BLACKLISTFILE}" ]; then if [ -e "${BLACKLISTFILE}" ]; then
cat "${BLACKLISTFILE}" >> ${DEBUG_LOG} cat "${BLACKLISTFILE}" >> ${DEBUG_LOG}
log_write log_write
@ -400,9 +380,7 @@ else
fi fi
echo "::: Writing adlists.list to debug log..." echo "::: Writing adlists.list to debug log..."
log_write "#######################################" header_write "adlists.list"
log_write "############ adlists.list #############"
log_write "#######################################"
if [ -e "${ADLISTSFILE}" ]; then if [ -e "${ADLISTSFILE}" ]; then
while read -r line; do while read -r line; do
if [ ! -z "${line}" ]; then if [ ! -z "${line}" ]; then
@ -421,9 +399,7 @@ fi
dumpPiHoleLog() { dumpPiHoleLog() {
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
log_write "#######################################" header_write "pihole.log"
log_write "############# pihole.log ##############"
log_write "#######################################"
if [ -e "${PIHOLELOG}" ]; then if [ -e "${PIHOLELOG}" ]; then
while true; do while true; do
tail -f "${PIHOLELOG}" >> ${DEBUG_LOG} tail -f "${PIHOLELOG}" >> ${DEBUG_LOG}