Last active
August 12, 2018 08:53
-
-
Save andreacioni/f6aef3285952e0197d3a2a7e38b559ee to your computer and use it in GitHub Desktop.
Check if Pi-Hole is up and running and restart it if needed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
#Tested with Pi-Hole v.4 | |
PI_HOST=localhost | |
echo "Checking Pi-Hole status" | |
curl http://$PI_HOST/admin/api.php?summary 2>/dev/null | grep '"status":"enabled"' > /dev/null | |
if [ $? -eq 0 ]; then | |
echo "Pi-Hole is up and running" | |
else | |
echo "Pi-Hole is NOT running!" | |
echo "Stopping Pi-Hole" | |
/usr/sbin/service pihole-FTL stop; /usr/sbin/service lighttpd stop | |
sleep 10s | |
echo "Starting Pi-Hole" | |
/usr/sbin/service pihole-FTL start; /usr/sbin/service lighttpd start | |
echo "Done" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment