1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-18 06:08:21 +00:00

Merge pull request #460 from pi-hole/LighttpdDebugLogging

Added lighttpd error.log to debug output
This commit is contained in:
Adam Warner 2016-04-15 21:56:58 +01:00
commit 2d03616c10

View File

@ -19,6 +19,7 @@ DEBUG_LOG="/var/log/pihole_debug.log"
DNSMASQFILE="/etc/dnsmasq.conf"
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
GRAVITYFILE="/etc/pihole/gravity.list"
HOSTSFILE="/etc/hosts"
WHITELISTFILE="/etc/pihole/whitelist.txt"
@ -53,6 +54,19 @@ else
fi
### Private functions exist here ###
function versionCheck {
echo "#######################################" >> $DEBUG_LOG
echo "########## Versions Section ###########" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
echo "Pi-hole Version: $TMP" >> $DEBUG_LOG
TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0)
echo "WebUI Version: $TMP" >> $DEBUG_LOG
echo >> $DEBUG_LOG
}
function compareWhitelist {
if [ ! -f "$WHITELISTMATCHES" ]; then
$SUDO touch $WHITELISTMATCHES
@ -126,12 +140,44 @@ function checkProcesses {
for i in "${PROCESSES[@]}"
do
echo "" >> $DEBUG_LOG
echo -n $i >> "$DEBUG_LOG"
echo -n "$i" >> "$DEBUG_LOG"
echo " processes status:" >> $DEBUG_LOG
$SUDO systemctl -l status $i >> "$DEBUG_LOG"
$SUDO systemctl -l status "$i" >> "$DEBUG_LOG"
done
}
function debugLighttpd {
echo "::: Writing lighttpd to debug log..."
echo "#######################################" >> $DEBUG_LOG
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$LIGHTTPDFILE" ]
then
while read -r line; do
if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG
fi
done < "$LIGHTTPDFILE"
echo >> $DEBUG_LOG
else
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd.conf file found\n"
fi
if [ -e "$LIGHTTPDERRFILE" ]
then
echo "#######################################" >> $DEBUG_LOG
echo "######### lighttpd error.log ##########" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG
else
echo "No lighttpd error.log file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd error.log file found\n"
fi
echo >> $DEBUG_LOG
}
### END FUNCTIONS ###
### Check Pi internet connections ###
@ -148,10 +194,12 @@ echo "Gateway check:" >> $DEBUG_LOG
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
echo >> $DEBUG_LOG
versionCheck
compareWhitelist
compareBlacklist
testNslookup
checkProcesses
debugLighttpd
echo "::: Writing dnsmasq.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG
@ -178,7 +226,6 @@ echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$PIHOLECONFFILE" ]
then
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
while read -r line; do
if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
@ -191,25 +238,6 @@ else
printf ":::\tNo 01-pihole.conf file found\n"
fi
echo "::: Writing lighttpd.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$LIGHTTPDFILE" ]
then
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
while read -r line; do
if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG
fi
done < "$LIGHTTPDFILE"
echo >> $DEBUG_LOG
else
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
printf ":::\tNo lighttpd.conf file found\n"
fi
echo "::: Writing size of gravity.list to debug log..."
echo "#######################################" >> $DEBUG_LOG
echo "############ gravity.list #############" >> $DEBUG_LOG
@ -283,7 +311,7 @@ fi
# Continuously append the pihole.log file to the pihole_debug.log file
function dumpPiHoleLog {
trap '{ echo -e "\nFinishing 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 pihole 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 "#######################################" >> $DEBUG_LOG
echo "############# pihole.log ##############" >> $DEBUG_LOG
@ -302,7 +330,8 @@ function dumpPiHoleLog {
# Anything to be done after capturing of pihole.log terminates
function finalWork {
echo "::: Finshed debugging!"
echo "::: Finshed debugging!"
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
}
trap finalWork EXIT