mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Organize functions and function calls.
Signed-off-by: Dan Schaper <dan.schaper@pi-hole.net>
This commit is contained in:
parent
f2fe84c9d3
commit
6cd4ff6d68
1 changed files with 72 additions and 69 deletions
|
@ -266,39 +266,42 @@ daemon_check() {
|
||||||
testResolver() {
|
testResolver() {
|
||||||
header_write "Resolver Functions Check"
|
header_write "Resolver Functions Check"
|
||||||
|
|
||||||
# Find a blocked url that has not been whitelisted.
|
local url
|
||||||
TESTURL="doubleclick.com"
|
local testurl
|
||||||
if [ -s "${WHITELISTMATCHES}" ]; then
|
local localdig
|
||||||
while read -r line; do
|
local piholedig
|
||||||
CUTURL=${line#*" "}
|
|
||||||
if [ "${CUTURL}" != "Pi-Hole.IsWorking.OK" ]; then
|
|
||||||
while read -r line2; do
|
|
||||||
CUTURL2=${line2#*" "}
|
|
||||||
if [ "${CUTURL}" != "${CUTURL2}" ]; then
|
|
||||||
TESTURL="${CUTURL}"
|
|
||||||
break 2
|
|
||||||
fi
|
|
||||||
done < "${WHITELISTMATCHES}"
|
|
||||||
fi
|
|
||||||
done < "${GRAVITYFILE}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log_write "Resolution of ${TESTURL} from Pi-hole:"
|
# Find a blocked url that has not been whitelisted.
|
||||||
LOCALDIG=$(dig "${TESTURL}" @127.0.0.1)
|
url=$(shuf -n 1 "${GRAVITYFILE}" | awk -F ' ' '{ print $2 }')
|
||||||
if [[ $? = 0 ]]; then
|
|
||||||
log_write "${LOCALDIG}"
|
testurl="${url:-doubleclick.com}"
|
||||||
|
|
||||||
|
|
||||||
|
log_write "Resolution of ${testurl} from Pi-hole (localhost):"
|
||||||
|
|
||||||
|
if localdig=$(dig "${testurl}" @localhost +short); then
|
||||||
|
log_write "${localdig}"
|
||||||
else
|
else
|
||||||
log_write "Failed to resolve ${TESTURL} on Pi-hole"
|
log_write "Failed to resolve ${testurl} on Pi-hole"
|
||||||
|
fi
|
||||||
|
log_write ""
|
||||||
|
|
||||||
|
log_write "Resolution of ${testurl} from Pi-hole (direct IP):"
|
||||||
|
|
||||||
|
if piholedig=$(dig "${testurl}" @"${IPV4_ADDRESS%/*}" +short); then
|
||||||
|
log_write "${piholedig}"
|
||||||
|
else
|
||||||
|
log_write "Failed to resolve ${testurl} on Pi-hole"
|
||||||
fi
|
fi
|
||||||
log_write ""
|
log_write ""
|
||||||
|
|
||||||
|
|
||||||
log_write "Resolution of ${TESTURL} from 8.8.8.8:"
|
log_write "Resolution of ${testurl} from 8.8.8.8:"
|
||||||
REMOTEDIG=$(dig "${TESTURL}" @8.8.8.8)
|
remotedig=$(dig "${testurl}" @8.8.8.8 +short)
|
||||||
if [[ $? = 0 ]]; then
|
if [[ $? = 0 ]]; then
|
||||||
log_write "${REMOTEDIG}"
|
log_write "${remotedig:-NXDOMAIN}"
|
||||||
else
|
else
|
||||||
log_write "Failed to resolve ${TESTURL} on 8.8.8.8"
|
log_write "Failed to resolve ${testurl} on 8.8.8.8"
|
||||||
fi
|
fi
|
||||||
log_write ""
|
log_write ""
|
||||||
|
|
||||||
|
@ -347,50 +350,6 @@ countdown() {
|
||||||
tuvix=$(( tuvix - 5 ))
|
tuvix=$(( tuvix - 5 ))
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
### END FUNCTIONS ###
|
|
||||||
|
|
||||||
# Gather version of required packages / repositories
|
|
||||||
version_check || echo "REQUIRED FILES MISSING"
|
|
||||||
# Check for newer setupVars storage file
|
|
||||||
source_file "/etc/pihole/setupVars.conf"
|
|
||||||
# Gather information about the running distribution
|
|
||||||
distro_check || echo "Distro Check soft fail"
|
|
||||||
# Gather processor type
|
|
||||||
processor_check || echo "Processor Check soft fail"
|
|
||||||
|
|
||||||
ip_check 6 ${IPV6_ADDRESS}
|
|
||||||
ip_check 4 ${IPV4_ADDRESS}
|
|
||||||
|
|
||||||
daemon_check lighttpd http
|
|
||||||
daemon_check dnsmasq domain
|
|
||||||
daemon_check pihole-FTL 4711
|
|
||||||
checkProcesses
|
|
||||||
testResolver
|
|
||||||
debugLighttpd
|
|
||||||
|
|
||||||
files_check "${DNSMASQFILE}"
|
|
||||||
dir_check "${DNSMASQCONFDIR}"
|
|
||||||
files_check "${WHITELISTFILE}"
|
|
||||||
files_check "${BLACKLISTFILE}"
|
|
||||||
files_check "${ADLISTFILE}"
|
|
||||||
|
|
||||||
|
|
||||||
header_write "Analyzing gravity.list"
|
|
||||||
|
|
||||||
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=$(grep -c ^ "${PIHOLELOG}") \
|
|
||||||
&& log_write "${PIHOLELOG} is ${pihole_length} lines long." \
|
|
||||||
|| log_echo "Warning: No pihole.log file found!"
|
|
||||||
|
|
||||||
pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \
|
|
||||||
&& log_write "${PIHOLELOG} is ${pihole_size}." \
|
|
||||||
|| log_echo "Warning: No pihole.log file found!"
|
|
||||||
|
|
||||||
|
|
||||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
dumpPiHoleLog() {
|
dumpPiHoleLog() {
|
||||||
|
@ -440,6 +399,50 @@ finalWork() {
|
||||||
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
### END FUNCTIONS ###
|
||||||
|
|
||||||
|
# Gather version of required packages / repositories
|
||||||
|
version_check || echo "REQUIRED FILES MISSING"
|
||||||
|
# Check for newer setupVars storage file
|
||||||
|
source_file "/etc/pihole/setupVars.conf"
|
||||||
|
# Gather information about the running distribution
|
||||||
|
distro_check || echo "Distro Check soft fail"
|
||||||
|
# Gather processor type
|
||||||
|
processor_check || echo "Processor Check soft fail"
|
||||||
|
|
||||||
|
ip_check 6 ${IPV6_ADDRESS}
|
||||||
|
ip_check 4 ${IPV4_ADDRESS}
|
||||||
|
|
||||||
|
daemon_check lighttpd http
|
||||||
|
daemon_check dnsmasq domain
|
||||||
|
daemon_check pihole-FTL 4711
|
||||||
|
checkProcesses
|
||||||
|
testResolver
|
||||||
|
debugLighttpd
|
||||||
|
|
||||||
|
files_check "${DNSMASQFILE}"
|
||||||
|
dir_check "${DNSMASQCONFDIR}"
|
||||||
|
files_check "${WHITELISTFILE}"
|
||||||
|
files_check "${BLACKLISTFILE}"
|
||||||
|
files_check "${ADLISTFILE}"
|
||||||
|
|
||||||
|
|
||||||
|
header_write "Analyzing gravity.list"
|
||||||
|
|
||||||
|
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=$(grep -c ^ "${PIHOLELOG}") \
|
||||||
|
&& log_write "${PIHOLELOG} is ${pihole_length} lines long." \
|
||||||
|
|| log_echo "Warning: No pihole.log file found!"
|
||||||
|
|
||||||
|
pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \
|
||||||
|
&& log_write "${PIHOLELOG} is ${pihole_size}." \
|
||||||
|
|| log_echo "Warning: No pihole.log file found!"
|
||||||
|
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
### Method calls for additional logging ###
|
### Method calls for additional logging ###
|
||||||
|
|
Loading…
Reference in a new issue