Created
June 14, 2024 09:22
-
-
Save benderni/1d876366b25084c404344793d12b8a8f to your computer and use it in GitHub Desktop.
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 | |
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md | |
PIHOLE_BASE="${PIHOLE_BASE:-$(pwd)}" | |
[[ -d "$PIHOLE_BASE" ]] || mkdir -p "$PIHOLE_BASE" || { echo "Couldn't create storage directory: $PIHOLE_BASE"; exit 1; } | |
# Note: FTLCONF_LOCAL_IPV4 should be replaced with your external ip. | |
docker run -d \ | |
--name pihole \ | |
-p 53:53/tcp -p 53:53/udp \ | |
-p 80:80 \ | |
-e TZ="Europe/Brussels" \ | |
-v "${PIHOLE_BASE}/etc-pihole:/etc/pihole" \ | |
-v "${PIHOLE_BASE}/etc-dnsmasq.d:/etc/dnsmasq.d" \ | |
--dns=127.0.0.1 --dns=1.1.1.1 \ | |
--restart=unless-stopped \ | |
--hostname pi.hole \ | |
-e VIRTUAL_HOST="pi.hole" \ | |
-e PROXY_LOCATION="pi.hole" \ | |
-e FTLCONF_LOCAL_IPV4="127.0.0.1" \ | |
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: http://${IP}/admin/" | |
exit 0 | |
else | |
sleep 3 | |
printf '.' | |
fi | |
if [ $i -eq 20 ] ; then | |
echo -e "\nTimed out waiting for Pi-hole start, consult 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