Merge pull request #11 from diginc/2.6.2_update
Updated version, support for custom DNS server override env vars
This commit is contained in:
commit
08f49d3ffa
2
AdminLTE
2
AdminLTE
|
@ -1 +1 @@
|
|||
Subproject commit a5e2008bce541daae115e143c558c3a820c0c7e5
|
||||
Subproject commit 25bc98348feae0b6ae3d43518043ea526d6ca3c1
|
|
@ -1 +1 @@
|
|||
v1.1.4
|
||||
v1.2
|
||||
|
|
27
README.md
27
README.md
|
@ -2,22 +2,14 @@ A Docker project to make lightweight x86 continers with [pi-hole](https://pi-hol
|
|||
|
||||
[![Build Status](https://travis-ci.org/diginc/docker-pi-hole.svg?branch=master)](https://travis-ci.org/diginc/docker-pi-hole)
|
||||
|
||||
## Docker tags
|
||||
|
||||
### Alpine
|
||||
|
||||
[![](https://badge.imagelayers.io/diginc/pi-hole:alpine.svg)](https://imagelayers.io/?images=diginc/pi-hole:alpine 'Get your own badge on imagelayers.io')
|
||||
This is an optimized docker using [alpine](https://hub.docker.com/_/alpine/) as its base. It uses nginx instead of lighttpd.
|
||||
|
||||
### Debian
|
||||
|
||||
[![](https://badge.imagelayers.io/diginc/pi-hole:debian.svg)](https://imagelayers.io/?images=diginc/pi-hole:debian 'Get your own badge on imagelayers.io')
|
||||
This version of the docker aims to be as close to a standard pi-hole installation by using the same base OS and the exact configs and scripts (minimally modified to get them working). This serves as a nice baseline for merging and testing upstream repository pi-hole changes.
|
||||
*April 25, 2016 Update*: piholeIP env var replaced by ServerIP env var, update your docker run/docker-compose configs accordingly please.
|
||||
|
||||
## Basic Docker Usage
|
||||
|
||||
If you have no other dockers using port 80 (if you do, read the list below for reverse proxy advice), the minimum options required to run this container are in the script [docker_run.sh](https://github.com/diginc/docker-pi-hole/blob/master/docker_run.sh):
|
||||
|
||||
To customize your upstream DNS servers you use docker environment varibales of *DNS1* and *DNS2* passed into docker at runtime. The default servers are Google's 8.8.8.8 and 8.8.4.4.
|
||||
|
||||
```
|
||||
IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
||||
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN -e piholeIP="$IP" --name pihole -d diginc/pi-hole
|
||||
|
@ -41,6 +33,19 @@ Here are some useful volume mount options to persist your history of stats in th
|
|||
All of these options get really long when strung together in one command, which is why I'm not going to show all the full commands variations. This is where [docker-compose](https://docs.docker.com/compose/install/) yml files come in handy for representing [really long docker commands in a readable file format](https://github.com/diginc/docker-pi-hole/blob/master/doco-example.yml).
|
||||
|
||||
|
||||
## Docker tags
|
||||
|
||||
### Alpine
|
||||
|
||||
[![](https://badge.imagelayers.io/diginc/pi-hole:alpine.svg)](https://imagelayers.io/?images=diginc/pi-hole:alpine 'Get your own badge on imagelayers.io')
|
||||
This is an optimized docker using [alpine](https://hub.docker.com/_/alpine/) as its base. It uses nginx instead of lighttpd.
|
||||
|
||||
### Debian
|
||||
|
||||
[![](https://badge.imagelayers.io/diginc/pi-hole:debian.svg)](https://imagelayers.io/?images=diginc/pi-hole:debian 'Get your own badge on imagelayers.io')
|
||||
This version of the docker aims to be as close to a standard pi-hole installation by using the same base OS and the exact configs and scripts (minimally modified to get them working). This serves as a nice baseline for merging and testing upstream repository pi-hole changes.
|
||||
|
||||
|
||||
## Advanced Usage and Notes
|
||||
|
||||
The standard pi-hole customization abilities apply to this docker, but with docker twists such as using docker volume mounts to map host stored file configurations over the container defaults. Volumes are also important to persist the configuration incase you have remove the pi-hole container which is a typical docker upgrade pattern.
|
||||
|
|
|
@ -15,8 +15,10 @@ COPY ./alpine/gravity.sh /usr/local/bin/
|
|||
COPY ./alpine/nginx.conf /etc/nginx/nginx.conf
|
||||
# Original upstream pihole code being used
|
||||
COPY ./pi-hole/adlists.default /etc/pihole/
|
||||
COPY ./pi-hole/pihole /usr/local/bin/
|
||||
COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/
|
||||
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.conf
|
||||
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
|
||||
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
|
||||
COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html
|
||||
COPY ./AdminLTE /var/www/html/admin
|
||||
COPY ./AdminLTE_version.txt /etc/
|
||||
|
@ -31,15 +33,14 @@ RUN mkdir -p /etc/pihole/ && \
|
|||
touch /var/log/pihole.log && \
|
||||
chmod 644 /var/log/pihole.log && \
|
||||
chown dnsmasq:root /var/log/pihole.log && \
|
||||
sed -i "s/@INT@/eth0/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@DNS1@/8.8.8.8/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@DNS2@/8.8.4.4/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
sed -i 's|"cd /etc/.pihole/ && git describe --tags --abbrev=0"|"cat /etc/pi-hole_version.txt"|g' /var/www/html/admin/footer.php && \
|
||||
sed -i 's|"cd /var/www/html/admin/ && git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php
|
||||
|
||||
# This chould be eliminated if the (upstream) files were +x in git
|
||||
# This chould be eliminated if all (upstream) files were +x in git
|
||||
RUN chmod +x /usr/local/bin/*.sh
|
||||
# Fix for docker
|
||||
|
||||
# Fix dnsmasq in docker
|
||||
RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf
|
||||
|
||||
COPY ./alpine/start.sh /
|
||||
|
|
|
@ -12,18 +12,19 @@
|
|||
|
||||
# Run this script as root or under sudo
|
||||
echo ":::"
|
||||
|
||||
if [[ $EUID -eq 0 ]];then
|
||||
echo "::: You are root."
|
||||
else
|
||||
echo "::: sudo will be used."
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the install cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
# Check if it is actually installed
|
||||
# If it isn't, exit because the install cannot complete
|
||||
if [[ $(dpkg-query -s sudo) ]];then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
else
|
||||
echo "::: Please install sudo or run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
piholeIPfile=/tmp/piholeIP
|
||||
|
@ -31,8 +32,8 @@ piholeIPv6file=/etc/pihole/.useIPv6
|
|||
|
||||
adListFile=/etc/pihole/adlists.list
|
||||
adListDefault=/etc/pihole/adlists.default
|
||||
whitelistScript=/usr/local/bin/whitelist.sh
|
||||
blacklistScript=/usr/local/bin/blacklist.sh
|
||||
whitelistScript=/opt/pihole/whitelist.sh
|
||||
blacklistScript=/opt/pihole/blacklist.sh
|
||||
|
||||
if [[ -f $piholeIPfile ]];then
|
||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
||||
|
@ -41,7 +42,7 @@ if [[ -f $piholeIPfile ]];then
|
|||
else
|
||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
||||
piholeIP=${piholeIPCIDR%/*}
|
||||
fi
|
||||
|
||||
|
@ -50,22 +51,20 @@ if [[ -f $piholeIPv6file ]];then
|
|||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
# Variables for various stages of downloading and formatting the list
|
||||
## Nate 3/26/2016 - Commented unused variables
|
||||
basename=pihole
|
||||
piholeDir=/etc/$basename
|
||||
adList=$piholeDir/gravity.list
|
||||
blacklist=$piholeDir/blacklist.txt
|
||||
whitelist=$piholeDir/whitelist.txt
|
||||
latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||
#blacklist=$piholeDir/blacklist.txt
|
||||
#whitelist=$piholeDir/whitelist.txt
|
||||
#latentWhitelist=$piholeDir/latentWhitelist.txt
|
||||
justDomainsExtension=domains
|
||||
matterandlight=$basename.0.matterandlight.txt
|
||||
supernova=$basename.1.supernova.txt
|
||||
eventHorizon=$basename.2.eventHorizon.txt
|
||||
accretionDisc=$basename.3.accretionDisc.txt
|
||||
eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||
#eyeOfTheNeedle=$basename.4.wormhole.txt
|
||||
|
||||
# After setting defaults, check if there's local overrides
|
||||
if [[ -r $piholeDir/pihole.conf ]];then
|
||||
|
@ -73,22 +72,6 @@ if [[ -r $piholeDir/pihole.conf ]];then
|
|||
. $piholeDir/pihole.conf
|
||||
fi
|
||||
|
||||
|
||||
spinner(){
|
||||
local pid=$1
|
||||
local delay=0.001
|
||||
local spinstr='/-\|'
|
||||
|
||||
spin='-\|/'
|
||||
i=0
|
||||
while $SUDO kill -0 $pid 2>/dev/null
|
||||
do
|
||||
i=$(( (i+1) %4 ))
|
||||
printf "\b${spin:$i:1}"
|
||||
sleep .1
|
||||
done
|
||||
printf "\b"
|
||||
}
|
||||
###########################
|
||||
# collapse - begin formation of pihole
|
||||
function gravity_collapse() {
|
||||
|
@ -99,7 +82,7 @@ function gravity_collapse() {
|
|||
#custom file found, use this instead of default
|
||||
echo -n "::: Custom adList file detected. Reading..."
|
||||
sources=()
|
||||
while read -a line; do
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||
echo "" > /dev/null
|
||||
|
@ -107,12 +90,12 @@ function gravity_collapse() {
|
|||
sources+=($line)
|
||||
fi
|
||||
done < $adListFile
|
||||
echo " done!"
|
||||
echo " done!"
|
||||
else
|
||||
#no custom file found, use defaults!
|
||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||
sources=()
|
||||
while read -a line; do
|
||||
sources=()
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
||||
echo "" > /dev/null
|
||||
|
@ -120,8 +103,8 @@ function gravity_collapse() {
|
|||
sources+=($line)
|
||||
fi
|
||||
done < $adListDefault
|
||||
echo " done!"
|
||||
fi
|
||||
echo " done!"
|
||||
fi
|
||||
|
||||
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
||||
if [[ -d $piholeDir ]];then
|
||||
|
@ -129,12 +112,12 @@ function gravity_collapse() {
|
|||
# Will update later, needed for existing installs, new installs should
|
||||
# create this directory as non-root
|
||||
$SUDO chmod 777 $piholeDir
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||
echo "."
|
||||
echo ":::"
|
||||
echo "::: Existing pihole directory found"
|
||||
else
|
||||
echo -n "::: Creating pihole directory..."
|
||||
mkdir $piholeDir & spinner $!
|
||||
echo " done!"
|
||||
echo "::: Creating pihole directory..."
|
||||
mkdir $piholeDir
|
||||
$SUDO chmod 777 $piholeDir
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -146,7 +129,7 @@ function gravity_patternCheck() {
|
|||
# Some of the blocklists are copyright, they need to be downloaded
|
||||
# and stored as is. They can be processed for content after they
|
||||
# have been saved.
|
||||
cp $patternBuffer $saveLocation
|
||||
cp "$patternBuffer" "$saveLocation"
|
||||
echo " List updated, transport successful!"
|
||||
else
|
||||
# curl didn't download any host files, probably because of the date check
|
||||
|
@ -169,17 +152,16 @@ function gravity_transport() {
|
|||
fi
|
||||
|
||||
# Silently curl url
|
||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
||||
# Check for list updates
|
||||
gravity_patternCheck $patternBuffer
|
||||
|
||||
gravity_patternCheck "$patternBuffer"
|
||||
# Cleanup
|
||||
rm -f $patternBuffer
|
||||
rm -f "$patternBuffer"
|
||||
}
|
||||
|
||||
# spinup - main gravity function
|
||||
function gravity_spinup() {
|
||||
echo "::: "
|
||||
echo ":::"
|
||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
||||
do
|
||||
|
@ -198,17 +180,17 @@ function gravity_spinup() {
|
|||
# Use a case statement to download lists that need special cURL commands
|
||||
# to complete properly and reset the user agent when required
|
||||
case "$domain" in
|
||||
"adblock.mahakala.is")
|
||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
||||
cmd_ext="-e http://forum.xda-developers.com/"
|
||||
;;
|
||||
"adblock.mahakala.is")
|
||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
||||
cmd_ext="-e http://forum.xda-developers.com/"
|
||||
;;
|
||||
|
||||
"pgl.yoyo.org")
|
||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||
;;
|
||||
"pgl.yoyo.org")
|
||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||
;;
|
||||
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
esac
|
||||
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||
done
|
||||
|
@ -216,81 +198,73 @@ function gravity_spinup() {
|
|||
|
||||
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
||||
function gravity_Schwarzchild() {
|
||||
echo "::: "
|
||||
echo "::: "
|
||||
# Find all active domains and compile them into one file and remove CRs
|
||||
echo -n "::: Aggregating list of domains..."
|
||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
||||
truncate -s 0 $piholeDir/$matterandlight
|
||||
for i in "${activeDomains[@]}"
|
||||
do
|
||||
cat $i |tr -d '\r' >> $piholeDir/$matterandlight
|
||||
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
|
||||
done
|
||||
echo " done!"
|
||||
|
||||
}
|
||||
|
||||
|
||||
function gravity_Blacklist(){
|
||||
# Append blacklist entries if they exist
|
||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
||||
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
||||
|
||||
$blacklistScript -f -nr -q > /dev/null
|
||||
|
||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||
echo " $numBlacklisted domain${plural} blacklisted!"
|
||||
|
||||
|
||||
echo " $numBlacklisted domain${plural} blacklisted!"
|
||||
}
|
||||
|
||||
|
||||
function gravity_Whitelist() {
|
||||
echo ":::"
|
||||
echo ":::"
|
||||
# Prevent our sources from being pulled into the hole
|
||||
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
||||
echo -n "::: Adding ${#sources[@]} ad list source${plural} to the whitelist..."
|
||||
|
||||
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
||||
|
||||
urls=()
|
||||
for url in ${sources[@]}
|
||||
for url in "${sources[@]}"
|
||||
do
|
||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
||||
urls=("${urls[@]}" $tmp)
|
||||
done
|
||||
echo " done!"
|
||||
|
||||
|
||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
||||
$whitelistScript -f -nr -q ${urls[@]} > /dev/null & spinner $!
|
||||
|
||||
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null
|
||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
||||
|
||||
|
||||
|
||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
||||
}
|
||||
|
||||
function gravity_unique() {
|
||||
# Sort and remove duplicates
|
||||
echo -n "::: Removing duplicate domains...."
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $!
|
||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon
|
||||
echo " done!"
|
||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
||||
echo "::: $numberOf unique domains trapped in the event horizon."
|
||||
}
|
||||
|
||||
function gravity_hostFormat() {
|
||||
# Format domain list as "192.168.x.x domain.com"
|
||||
# Format domain list as "192.168.x.x domain.com"
|
||||
echo "::: Formatting domains into a HOSTS file..."
|
||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
||||
echo -e "$piholeIP Pi-Hole.IsWorking.OK \n$piholeIPv6 Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
|
||||
else
|
||||
# Otherwise, just create gravity.list as normal using IPv4
|
||||
#Add dummy domain Pi-Hole.IsWorking.OK to the top of gravity.list to make ping result return a friendlier looking domain!
|
||||
echo -e "$piholeIP Pi-Hole.IsWorking.OK" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
fi
|
||||
hostname=$(</etc/hostname)
|
||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
||||
if [[ -n $piholeIPv6 ]];then
|
||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||
echo -e "$piholeIP $hostname\n$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
else
|
||||
# Otherwise, just create gravity.list as normal using IPv4
|
||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
||||
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc
|
||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
||||
fi
|
||||
|
||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||
cp $piholeDir/$accretionDisc $adList
|
||||
}
|
||||
|
@ -301,52 +275,55 @@ function gravity_blackbody() {
|
|||
for file in $piholeDir/*.$justDomainsExtension
|
||||
do
|
||||
# If list is in active array then leave it (noop) else rm the list
|
||||
if [[ " ${activeDomains[@]} " =~ " ${file} " ]]; then
|
||||
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||
:
|
||||
else
|
||||
rm -f $file
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function gravity_advanced() {
|
||||
|
||||
|
||||
# Remove comments and print only the domain name
|
||||
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
||||
# This helps with that and makes it easier to read
|
||||
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||
echo -n "::: Formatting list of domains to remove comments...."
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $!
|
||||
echo " done!"
|
||||
|
||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova
|
||||
echo " done!"
|
||||
|
||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
||||
echo "::: $numberOf domains being pulled in by gravity..."
|
||||
|
||||
|
||||
gravity_unique
|
||||
|
||||
}
|
||||
|
||||
function gravity_reload() {
|
||||
#Clear no longer needed files...
|
||||
echo ":::"
|
||||
echo -n "::: Cleaning up un-needed files..."
|
||||
$SUDO rm /etc/pihole/pihole.*
|
||||
$SUDO rm $piholeDir/pihole.*.txt
|
||||
echo " done!"
|
||||
|
||||
|
||||
# Reload hosts file
|
||||
echo ":::"
|
||||
echo -n "::: Refresh lists in dnsmasq..."
|
||||
|
||||
#ensure /etc/dnsmasq.d/01-pihole.conf is pointing at the correct list!
|
||||
#First escape forward slashes in the path:
|
||||
adList=${adList//\//\\\/}
|
||||
#Now replace the line in dnsmasq file
|
||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||
dnsmasqPid=$(pidof dnsmasq)
|
||||
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \;
|
||||
|
||||
if [[ $dnsmasqPid ]]; then
|
||||
# service already running - reload config
|
||||
$SUDO kill -HUP $dnsmasqPid & spinner $!
|
||||
$SUDO kill -HUP "$dnsmasqPid"
|
||||
else
|
||||
# service not running, start it up
|
||||
$SUDO service dnsmasq start & spinner $!
|
||||
$SUDO service dnsmasq start
|
||||
fi
|
||||
echo " done!"
|
||||
}
|
||||
|
|
|
@ -1,18 +1,29 @@
|
|||
#!/bin/sh
|
||||
dnsmasq --test || exit 1
|
||||
php-fpm -t || exit 1
|
||||
nginx -t || exit 1
|
||||
|
||||
if [ -n "$piholeIP" ] ; then
|
||||
if [ -n "$ServerIP" ] ; then
|
||||
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
|
||||
echo "$piholeIP" > /tmp/piholeIP;
|
||||
echo "$ServerIP" > /tmp/piholeIP;
|
||||
else
|
||||
echo "ERROR: It is required you pass an environment variables of 'piholeIP' with the IP of your docker host which you are passing 80/53 from"
|
||||
echo "ERROR: To function correctly you must pass an environment variables of 'ServerIP' into the docker container with the IP of your docker host from which you are passing web (80) and dns (53) ports from"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
gravity.sh # pi-hole version minus the service dnsmasq start
|
||||
dnsmasq
|
||||
dnsType='default'
|
||||
DNS1=${DNS1:-'8.8.8.8'}
|
||||
DNS2=${DNS2:-'8.8.4.4'}
|
||||
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
|
||||
dnsType='custom'
|
||||
fi;
|
||||
|
||||
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
|
||||
sed -i "s/@DNS1@/$DNS1/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
|
||||
dnsmasq --test -7 /etc/dnsmasq.d || exit 1
|
||||
php-fpm -t || exit 1
|
||||
nginx -t || exit 1
|
||||
|
||||
gravity.sh # pi-hole version without 'service dnsmasq start'
|
||||
dnsmasq -7 /etc/dnsmasq.d
|
||||
php-fpm
|
||||
nginx
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ RUN apt-get -q update && \
|
|||
# Original upstream pihole code being used
|
||||
COPY ./pi-hole/gravity.sh /usr/local/bin/
|
||||
COPY ./pi-hole/adlists.default /etc/pihole/
|
||||
COPY ./pi-hole/pihole /usr/local/bin/
|
||||
COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/
|
||||
COPY ./pi-hole/advanced/lighttpd.conf /etc/lighttpd/lighttpd.conf
|
||||
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.conf
|
||||
COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf
|
||||
COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/
|
||||
COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html
|
||||
COPY ./AdminLTE /var/www/html/admin
|
||||
COPY ./AdminLTE_version.txt /etc/
|
||||
|
@ -37,17 +39,20 @@ RUN mkdir -p /etc/pihole/ && \
|
|||
touch /var/log/pihole.log && \
|
||||
chmod 644 /var/log/pihole.log && \
|
||||
chown dnsmasq:root /var/log/pihole.log && \
|
||||
sed -i "s/@INT@/eth0/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@DNS1@/8.8.8.8/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@DNS2@/8.8.4.4/" /etc/dnsmasq.conf && \
|
||||
sed -i "s/@INT@/eth0/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
sed -i 's|"cd /etc/.pihole/ && git describe --tags --abbrev=0"|"cat /etc/pi-hole_version.txt"|g' /var/www/html/admin/footer.php && \
|
||||
sed -i 's|"cd /var/www/html/admin/ && git describe --tags --abbrev=0"|"cat /etc/AdminLTE_version.txt"|g' /var/www/html/admin/footer.php
|
||||
|
||||
# This chould be eliminated if the files were +x in git
|
||||
# This chould be eliminated if all (upstream) files were +x in git
|
||||
RUN chmod +x /usr/local/bin/*.sh
|
||||
# Fix just for docker
|
||||
|
||||
# Fix dnsmasq in docker
|
||||
RUN grep -q '^user=root' || echo 'user=root' >> /etc/dnsmasq.conf
|
||||
|
||||
COPY ./debian/start.sh /
|
||||
|
||||
EXPOSE 53 53/udp
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/tini", "--"]
|
||||
CMD /start.sh
|
||||
|
|
|
@ -1,16 +1,27 @@
|
|||
#!/bin/sh
|
||||
dnsmasq --test || exit 1
|
||||
lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1
|
||||
|
||||
if [ -n "$piholeIP" ] ; then
|
||||
if [ -n "$ServerIP" ] ; then
|
||||
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
|
||||
echo "$piholeIP" > /tmp/piholeIP;
|
||||
echo "$ServerIP" > /tmp/piholeIP;
|
||||
else
|
||||
echo "ERROR: It is required you pass an environment variables of 'piholeIP' with the IP of your docker host which you are passing 80/53 from"
|
||||
echo "ERROR: It is required you pass an environment variables of 'ServerIP' with the IP of your docker host which you are passing 80/53 from"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
dnsType='default'
|
||||
DNS1=${DNS1:-'8.8.8.8'}
|
||||
DNS2=${DNS2:-'8.8.4.4'}
|
||||
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
|
||||
dnsType='custom'
|
||||
fi;
|
||||
|
||||
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
|
||||
sed -i "s/@DNS1@/$DNS1/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \
|
||||
|
||||
dnsmasq --test -7 /etc/dnsmasq.d || exit 1
|
||||
lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1
|
||||
|
||||
gravity.sh # dnsmasq start included
|
||||
service lighttpd start
|
||||
|
||||
tail -f /var/log/lighttpd/*.log /var/log/pihole.log
|
||||
tail -F /var/log/lighttpd/*.log /var/log/pihole.log
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
docker build -f alpine.docker -t dockerpihole_alpine .
|
||||
docker build -f debian.docker -t dockerpihole_debian .
|
||||
|
||||
IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
||||
|
||||
docker run -it --rm --cap-add=NET_ADMIN \
|
||||
-p 5053:53/tcp \
|
||||
-p 5053:53/udp \
|
||||
-p 5080:80 \
|
||||
-e ServerIP="$IP" \
|
||||
$@ \
|
||||
dockerpihole_${image:-alpine}
|
|
@ -1,4 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
image=${1:-'diginc/pihole:alpine'}
|
||||
IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
||||
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN -e piholeIP="$IP" --name pihole -d dockerhole_alpine
|
||||
|
||||
# Default ports + daemonized docker container
|
||||
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \
|
||||
--cap-add=NET_ADMIN \
|
||||
-e piholeIP="$IP" \
|
||||
--name pihole \
|
||||
-d $image
|
||||
|
|
2
pi-hole
2
pi-hole
|
@ -1 +1 @@
|
|||
Subproject commit 396c7ab9eebf75e1364056113d50d1c78342d342
|
||||
Subproject commit 38539972958fa66d21dd7cec1ec5c1141d4c85cb
|
|
@ -1 +1 @@
|
|||
v2.5.3
|
||||
v2.6.2
|
||||
|
|
Loading…
Reference in New Issue