Created
January 10, 2020 19:27
-
-
Save mthadley/f2d4a8ee2d304360d8989f40e9a4e849 to your computer and use it in GitHub Desktop.
Pihole startup script
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 | |
# Remove existing container | |
docker stop pihole | |
docker rm pihole | |
docker run -d \ | |
--name pihole \ | |
-e TZ="America/Los_Angeles" \ | |
-e ServerIP="192.168.1.201" \ | |
-v "$(pwd)/etc-pihole/:/etc/pihole/" \ | |
-v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ | |
--network host \ | |
--restart=unless-stopped \ | |
pihole/pihole:latest | |
printf 'Starting up pihole container ' | |
for i in $(seq 1 20); do | |
if [ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" == "healthy" ] ; then | |
printf ' OK' | |
echo -e "\n$(docker logs pihole 2> /dev/null | grep 'password:') for your pi-hole: https://${IP}/admin/" | |
exit 0 | |
else | |
sleep 3 | |
printf '.' | |
fi | |
if [ $i -eq 20 ] ; then | |
echo -e "\nTimed out waiting for Pi-hole start, consult check your container logs for more info (\`docker logs pihole\`)" | |
exit 1 | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment