Automatically upload log file to sprunge.us

==========================================

Adds the function to upload log file. When their are
connection issues, the log file will be output in the
original fasion. Otherwise, the user will be presented
now with a link the resembles sprunge.us/XXXX
This commit is contained in:
Daniel 2016-07-03 17:54:59 -04:00
parent 024b741552
commit 7f8ad44b00

View file

@ -330,8 +330,16 @@ function dumpPiHoleLog {
# Anything to be done after capturing of pihole.log terminates
function finalWork {
echo "::: Finshed debugging!"
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
echo "::: Finshed debugging!"
SPRUNGE=$(cat /var/log/pihole_debug.log | curl --silent --connect-timeout 5 -F 'sprunge=<-' http://sprunge.us)
# Check if sprunge.us is reachable.
if [ -n "$SPRUNGE" ]
then
echo "::: Debug log can be found at : $SPRUNGE"
else
echo "::: Debug log can be found at : /var/log/pihole_debug.log"
fi
}
trap finalWork EXIT