Skip to content

Commit

Permalink
Merge pull request #19 from slime3000fly/Pi
Browse files Browse the repository at this point in the history
Pi-hole
  • Loading branch information
slime3000fly authored Oct 27, 2024
2 parents 6131c58 + a26575b commit f21c63a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 79 deletions.
Binary file added Pi-hole/.config.sh.swp
Binary file not shown.
19 changes: 19 additions & 0 deletions Pi-hole/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# This is repo wich script to automate Pi-hole instalation
##Requirements
To set up Pi-hole using this script, you should have a Debian-based operating system.
Installation
1. Clone this repository.
2. Run the following command to execute the installation script:
```bash
bash install.sh
This script will:
- Install Docker.
- Set up the Pi-hole container.
- Insert a specified URL into the adlist database.


# Helpfull link and advice how to configure pi-hole
## Adlist updater:
https://github.com/koljah-de/pi-hole-adlists-updater
## Pi-hole restore CLI
https://github.com/chamilad/pihole-restore
## Update Rasbbery-pi kernetl
https://github.com/raspberrypi/linux/issues/6170

# TODO:
- add vpn cofiguration
- add homepage for entire setup
- add nas server
28 changes: 0 additions & 28 deletions Pi-hole/config.sh

This file was deleted.

5 changes: 2 additions & 3 deletions Pi-hole/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ services:
WEBPASSWORD: 'admin'
# Volumes store your data between container upgrades
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
- './script:/tmp'
- '/etc-pihole:/etc/pihole'
- '/etc-dnsmasq.d:/etc/dnsmasq.d'
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
# cap_add:
# - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
Expand Down
96 changes: 48 additions & 48 deletions Pi-hole/instal.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/bin/bash

set -e

# Installing Nginx
echo -e "\e[34m Instal ngnix\e[0m"
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y nginx

# Configuring reverse proxy
sudo cat <<EOF > /etc/nginx/sites-available/reverse-proxy
server {
listen 80;
# listen 53 udp;
# listen 53;
resolver 127.0.0.1 valid=30s;
location / {
proxy_pass http://localhost:5353; # Port on which Pi-hole operates inside Docker container
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
}
EOF

# Enabling reverse proxy configuration
if [ ! -L /etc/nginx/sites-enabled/reverse-proxy ]; then
sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/reverse-proxy
else
echo "Symbolic link for reverse-proxy already exists."
fi

# set -e
#
# # Installing Nginx
# echo -e "\e[34m Instal ngnix\e[0m"
# sudo apt-get update
# sudo apt-get upgrade -y
# sudo apt-get install -y nginx
#
# # Configuring reverse proxy
# sudo cat <<EOF > /etc/nginx/sites-available/reverse-proxy
# server {
# listen 80;
# # listen 53 udp;
# # listen 53;
#
# resolver 127.0.0.1 valid=30s;
#
# location / {
# proxy_pass http://localhost:5353; # Port on which Pi-hole operates inside Docker container
# proxy_set_header Host \$host;
# proxy_set_header X-Real-IP \$remote_addr;
# proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto \$scheme;
# }
# }
# EOF
#
# # Enabling reverse proxy configuration
# if [ ! -L /etc/nginx/sites-enabled/reverse-proxy ]; then
# sudo ln -s /etc/nginx/sites-available/reverse-proxy /etc/nginx/sites-enabled/reverse-proxy
# else
# echo "Symbolic link for reverse-proxy already exists."
# fi
#
# Restarting Nginx server
echo -e "\e[34m restart nginx\e[0m"
sudo systemctl restart nginx
#echo -e "\e[34m restart nginx\e[0m"
#sudo systemctl restart nginx

# install docker
echo -e "\e[34m Docker instalation\e[0m"
Expand Down Expand Up @@ -67,7 +67,7 @@ sudo apt install docker-compose -y
# Run Pi-hole in docker
docker-compose up -d

echo "waiting for container"
echo -e "\e[343m waiting for container\e[0m"
while true; do
if [ $( docker ps -a | grep pihole | wc -l ) -gt 0 ]; then
echo "Container run!!!"
Expand All @@ -78,16 +78,16 @@ while true; do
fi
done

docker cp config.sh pihole:/tmp
docker cp pi-hole_restore.tar.gz pihole:/tmp
docker exec -it pihole sh -c "./tmp/config.sh"
echo -e "\e[34m importing addlist\e[0m"
docker exec -it pihole sqlite3 /etc/pihole/gravity.db "INSERT INTO adlist (address) VALUES ('https://gitlab.com/hagezi/mirror/-/raw/main/dns-blocklists/adblock/pro.txt');"
docker exec -it pihole pihole -g

#stop docker service to change cofnfiguration of pi-hole container
id=docker inspect --format="{{.Id}}" pihole
docker stop pihole
systemctl stop docker

# change port host 8080 to 80
sed -i 's/"8080"/"80"/g' /var/lib/docker/containers/$id/hostconfig.json
# Check for errors and retry if necessary
if [ $? -ne 0 ]; then
echo "Error occurred while building gravity tree. Retrying in 10 seconds..."
sleep 10
docker exec -it pihole pihole -g
fi

systemctl start
# Print DONE message
echo -e "\033[0;32mDONE\033[0m"
Binary file removed Pi-hole/pi-hole_restore.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CI/CD pipelines have been set up using GitHub Actions. Any change in the reposit
3. [Vagrant](##installation-and-Configuration-Vagrant)
4. [K8S](K8S/README.md)
5. [DockerCompose](DockerCompose/README.md)
6. [PiHole](Pi-hole/README.md)

## Folders
### Installation and Configuration Vagrant
Expand Down

0 comments on commit f21c63a

Please sign in to comment.