-
Notifications
You must be signed in to change notification settings - Fork 0
/
pihole.sh
42 lines (38 loc) · 1.63 KB
/
pihole.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp \
-p 80:80 \
-p 443:443 \
-p 8080:8080 \
-e TZ="America/Chicago" \
-v "$(pwd)/etc-pihole/:/etc/pihole/" \
-v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
--dns=127.0.0.1 --dns=1.1.1.1 \
--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
sudo docker exec pihole sh -c "sudo apt update && sudo apt-get --yes upgrade && sudo apt-get install python3 --yes && sudo apt install --yes python3-pip && pip3 install flask"
printf ' OK'
echo -e "\n$(docker logs pihole 2> /dev/null | grep 'password:') for your pi-hole: https://${IP}/admin/"
sudo docker exec -d pihole mkdir /home/network
sudo docker cp blockdomains.sh pihole:/home/network/
sudo docker cp unblockdomains.sh pihole:/home/network/
sudo docker cp network.py pihole:/home/network/
sudo docker exec -d pihole touch /home/network/log.txt
sudo docker exec -d pihole sudo chmod u+x /home/network/blockdomains.sh
sudo docker exec -d pihole sudo chmod u+x /home/network/unblockdomains.sh
sudo docker exec -d pihole sudo chmod u+x /home/network/network.py
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;