mirror of
https://github.com/pi-hole/pi-hole
synced 2025-02-04 12:21:07 +00:00
Reduce header verbosity. New header writer.
This commit is contained in:
parent
4839953328
commit
01f17f9cbb
@ -50,31 +50,33 @@ 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)" \
|
||||||
&& log_write "WebUI Version: $admin_ver" || log_write "Pi-hole Admin Pages git repository not detected."
|
&& log_write "WebUI Version: $admin_ver" || log_write "Pi-hole Admin Pages git repository not detected."
|
||||||
|
|
||||||
echo "::: Writing lighttpd version to logfile."
|
echo "::: Writing lighttpd version to logfile."
|
||||||
light_ver="$(lighttpd -v |& head -n1)" && log_write "${light_ver}" || log_write "lighttpd not installed."
|
light_ver="$(lighttpd -v |& head -n1)" && log_write "${light_ver}" || log_write "lighttpd not installed."
|
||||||
|
|
||||||
echo "::: Writing PHP version to logfile."
|
echo "::: Writing PHP version to logfile."
|
||||||
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
|
||||||
}
|
}
|
||||||
|
|
||||||
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..."
|
||||||
setupVars=/etc/pihole/setupVars.conf
|
setupVars=/etc/pihole/setupVars.conf
|
||||||
if [[ -f ${setupVars} ]];then
|
if [[ -f ${setupVars} ]];then
|
||||||
echo " found!"
|
echo " found!"
|
||||||
@ -93,30 +95,26 @@ files_check() {
|
|||||||
piholeInterface="%${piholeInterface}"
|
piholeInterface="%${piholeInterface}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " NOT FOUND!"
|
echo " NOT FOUND!"
|
||||||
log_write "/etc/pihole/setupVars.conf not found!"
|
log_write "/etc/pihole/setupVars.conf not found!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
echo "::: Writing OS Distribution release to logfile."
|
echo "::: Writing OS Distribution release to logfile."
|
||||||
log_write "${TMP}"
|
log_write "${TMP}"
|
||||||
log_write ""
|
log_write ""
|
||||||
}
|
}
|
||||||
|
|
||||||
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) }')"
|
||||||
log_write "${IPADDR}"
|
log_write "${IPADDR}"
|
||||||
|
|
||||||
@ -124,10 +122,10 @@ ip_check() {
|
|||||||
&& log_write "${IP6ADDR}" || log_write "No IPv6 addresses found."
|
&& log_write "${IP6ADDR}" || log_write "No IPv6 addresses found."
|
||||||
log_write ""
|
log_write ""
|
||||||
|
|
||||||
echo "::: Locating default gateway and checking connectivity"
|
echo "::: Locating default gateway and checking connectivity"
|
||||||
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
|
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
echo "::: Pinging default IPv4 gateway..."
|
echo "::: Pinging default IPv4 gateway..."
|
||||||
GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3)
|
GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
log_write "IPv4 Gateway check:"
|
log_write "IPv4 Gateway check:"
|
||||||
@ -137,7 +135,7 @@ ip_check() {
|
|||||||
log_write "${GATEWAY_CHECK}"
|
log_write "${GATEWAY_CHECK}"
|
||||||
log_write ""
|
log_write ""
|
||||||
|
|
||||||
echo "::: Pinging Internet via IPv4..."
|
echo "::: Pinging Internet via IPv4..."
|
||||||
INET_CHECK=$(ping -q -w 5 -c 3 -n 8.8.8.8 | tail -n3)
|
INET_CHECK=$(ping -q -w 5 -c 3 -n 8.8.8.8 | tail -n3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
log_write "IPv4 Internet check:"
|
log_write "IPv4 Internet check:"
|
||||||
@ -150,7 +148,7 @@ ip_check() {
|
|||||||
|
|
||||||
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
echo "::: Pinging default IPv6 gateway..."
|
echo "::: Pinging default IPv6 gateway..."
|
||||||
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}""${piholeInterface}" | tail -n3)
|
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}""${piholeInterface}" | tail -n3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
log_write "IPv6 Gateway check:"
|
log_write "IPv6 Gateway check:"
|
||||||
@ -158,7 +156,7 @@ ip_check() {
|
|||||||
log_write "IPv6 Gateway check failed:"
|
log_write "IPv6 Gateway check failed:"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Pinging Internet via IPv6..."
|
echo "::: Pinging Internet via IPv6..."
|
||||||
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n 2001:4860:4860::8888"${piholeInterface}" | tail -n3)
|
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n 2001:4860:4860::8888"${piholeInterface}" | tail -n3)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
log_write "IPv6 Internet check:"
|
log_write "IPv6 Internet check:"
|
||||||
@ -176,15 +174,13 @@ 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
|
||||||
log_write "This Pi-hole is: $(hostname)"
|
log_write "This Pi-hole is: $(hostname)"
|
||||||
|
|
||||||
echo "::: Writing hosts file to debug log..."
|
echo "::: Writing hosts file to debug log..."
|
||||||
log_write "### Hosts ###"
|
log_write "### Hosts ###"
|
||||||
|
|
||||||
if [ -e "${HOSTSFILE}" ]; then
|
if [ -e "${HOSTSFILE}" ]; then
|
||||||
@ -197,11 +193,9 @@ 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."
|
||||||
|
|
||||||
lsof -i :80 >> ${DEBUG_LOG}
|
lsof -i :80 >> ${DEBUG_LOG}
|
||||||
lsof -i :53 >> ${DEBUG_LOG}
|
lsof -i :53 >> ${DEBUG_LOG}
|
||||||
@ -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,11 +260,9 @@ testResolver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkProcesses() {
|
checkProcesses() {
|
||||||
log_write "#######################################"
|
header_write "Processes Check"
|
||||||
log_write "########### Processes Check ###########"
|
|
||||||
log_write "#######################################"
|
echo "::: Logging status of lighttpd and dnsmasq..."
|
||||||
log_write ":::"
|
|
||||||
echo "::: Logging status of lighttpd and dnsmasq..."
|
|
||||||
PROCESSES=( lighttpd dnsmasq )
|
PROCESSES=( lighttpd dnsmasq )
|
||||||
for i in "${PROCESSES[@]}"; do
|
for i in "${PROCESSES[@]}"; do
|
||||||
log_write ""
|
log_write ""
|
||||||
@ -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}
|
||||||
|
Loading…
Reference in New Issue
Block a user