add health check

This commit is contained in:
Kameron Kenny - pi501 2025-06-30 13:38:45 -04:00
parent 53c07e85a7
commit 46fbb63489
1 changed files with 25 additions and 0 deletions

25
health_check.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
TIMEOUT=2
function no_good {
cd /home/kkenny/src/docker/pihole
git pull
echo "[$(date)] $1 has failed, restarting." >> health.log
docker compose down >> health.log 2>&1
docker compose up $1 -d >> health.log 2>&1
exit 1
}
case $(hostname) in
pi501)
dig google.com @10.200.53.241 >/dev/null 2>&1 || no_good "pihole1"
;;
pi502)
dig google.com @10.200.53.242 >/dev/null 2>&1 || no_good "pihole2"
;;
pi503)
dig google.com @10.200.53.243 >/dev/null 2>&1 || no_good "pihole3"
;;
esac