Skip to content

Instantly share code, notes, and snippets.

@andreacioni
Last active August 12, 2018 08:53
Show Gist options
  • Save andreacioni/f6aef3285952e0197d3a2a7e38b559ee to your computer and use it in GitHub Desktop.
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
#/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