Skip to content

Commit 5c21f14

Browse files
authored
Merge pull request pi-hole#741 from pi-hole/dev
v5.2.2 and various to master
2 parents c525df5 + 99b6dc9 commit 5c21f14

8 files changed

+76
-74
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Please review the following before opening a pull request (PR) to help your PR g
66
* To ensure proper testing and quality control, target any code change pull requests against `dev` branch.
77

88
* Make sure the tests pass
9-
* Take a look at [TESTING.md](TESTING.md) to see how to run tests locally so you do not have to push all your code to a PR and have travis-ci run it.
9+
* Take a look at [TESTING.md](TESTING.md) to see how to run tests locally so you do not have to push all your code to a PR and have GitHub Actions run it.
1010
* Your tests will probably run faster locally and you get a faster feedback loop.

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ There are other environment variables if you want to customize various things in
102102
| `ADMIN_EMAIL: <email address>`<br/> *Optional Default: ''* | Set an administrative contact address for the Block Page
103103
| `TZ: <Timezone>`<br/> **Recommended** *Default: UTC* | Set your [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to make sure logs rotate at local midnight instead of at UTC midnight.
104104
| `WEBPASSWORD: <Admin password>`<br/> **Recommended** *Default: random* | http://pi.hole/admin password. Run `docker logs pihole \| grep random` to find your random pass.
105-
| `DNS1: <IP>`<br/> *Optional* *Default: 8.8.8.8* | Primary upstream DNS provider, default is google DNS
106-
| `DNS2: <IP>`<br/> *Optional* *Default: 8.8.4.4* | Secondary upstream DNS provider, default is google DNS, `no` if only one DNS should used
105+
| `PIHOLE_DNS_: <IPs delimited by ;>`<br/> *Optional* *Default: 8.8.8.8;8.8.4.4* | Upstream DNS server(s) for Pi-hole to forward queries to, seperated by a semicolon <br/> (supports non-standard ports with `#[port number]`) e.g `127.0.0.1#5053;8.8.8.8;8.8.4.4`
107106
| `DNSSEC: <"true"\|"false">`<br/> *Optional* *Default: "false"* | Enable DNSSEC support
108107
| `DNS_BOGUS_PRIV: <"true"\|"false">`<br/> *Optional* *Default: "true"* | Enable forwarding of reverse lookups for private ranges
109108
| `DNS_FQDN_REQUIRED: <"true"\|"false">`<br/> *Optional* *Default: true* | Never forward non-FQDNs
@@ -122,6 +121,7 @@ There are other environment variables if you want to customize various things in
122121
| `TEMPERATUREUNIT`: <c\|k\|f><br/>*Optional Default: c* | Set preferred temperature unit to `c`: Celsius, `k`: Kelvin, or `f` Fahrenheit units.
123122
| `WEBUIBOXEDLAYOUT: <boxed\|traditional>`<br/>*Optional Default: boxed* | Use boxed layout (helpful when working on large screens)
124123
| `SKIPGRAVITYONBOOT`: <Not Set\|1><br/> *Optional Default: Not Set* | Use this option to skip updating the Gravity Database when booting up the container. By default this environment variable is not set so the Gravity Database will be updated when the container starts up. Setting this environment variable to 1 (or anything) will cause the Gravity Database to not be updated when container starts up.
124+
| `QUERY_LOGGING: <"true"\|"false">`<br/> *Optional* *Default: "true"* | Enable query logging or not.
125125

126126
## Deprecated environment variables:
127127
While these may still work, they are likely to be removed in a future version. Where applicible, alternative variable names are indicated. Please review the table above for usage of the alternative variables
@@ -130,8 +130,10 @@ While these may still work, they are likely to be removed in a future version. W
130130
| ----------------------- | ----------- | ----------- |
131131
| `CONDITIONAL_FORWARDING: <"true"\|"false">`<br/> *Optional* *Default: "false"* | Enable DNS conditional forwarding for device name resolution | `REV_SERVER`|
132132
| `CONDITIONAL_FORWARDING_IP: <Router's IP>`<br/> *Optional* | If conditional forwarding is enabled, set the IP of the local network router | `REV_SERVER_TARGET` |
133-
| `CONDITIONAL_FORWARDING_DOMAIN: <Network Domain>`<br/> *Optional* | If conditional forwarding is enabled, set the domain of the local network router | `REV_SERVER_DOMAIN` |
133+
| `CONDITIONAL_FORWARDING_DOMAIN: <Network Domain>`<br/> *Optional* | If conditional forwarding is enabled, set the domain of the local network router | `REV_SERVER_DOMAIN` |
134134
| `CONDITIONAL_FORWARDING_REVERSE: <Reverse DNS>`<br/> *Optional* | If conditional forwarding is enabled, set the reverse DNS of the local network router (e.g. `0.168.192.in-addr.arpa`) | `REV_SERVER_CIDR` |
135+
| `DNS1: <IP>`<br/> *Optional* *Default: 8.8.8.8* | Primary upstream DNS provider, default is google DNS | `PIHOLE_DNS_` |
136+
| `DNS2: <IP>`<br/> *Optional* *Default: 8.8.4.4* | Secondary upstream DNS provider, default is google DNS, `no` if only one DNS should used | `PIHOLE_DNS_` |
135137

136138
To use these env vars in docker run format style them like: `-e DNS1=1.1.1.1`
137139

TESTING.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# Prerequisites
22

3-
Make sure you have bash, docker. Python and some test hacks are crammed into the `Dockerfile_build` file for now. Revisions in the future may re-enable running python on your host (not just in docker).
3+
Make sure you have bash & docker.
4+
Python and some test hacks are crammed into the `Dockerfile_build` file for now.
5+
Revisions in the future may re-enable running python on your host (not just in docker).
46

57
# Running tests locally
68

79
`ARCH=amd64 ./gh-actions-test.sh`
810

9-
Should result in :
11+
Should result in:
1012

11-
- An image named `pihole:amd64` being build
12-
- Tests being ran to confirm the image doesnt have any regressions
13+
- An image named `pihole:amd64` being built
14+
- Tests being ran to confirm the image doesn't have any regressions
1315

1416
# Local image names
1517

1618
Docker images built by `Dockerfile.py` are named the same but stripped of the `pihole/` docker repository namespace.
1719

1820
e.g. `pi-hole:debian_amd64` or `pi-hole-multiarch:debian_arm64`
1921

20-
You can run the multiarch images on an amd64 development system if you [enable binfmt-support as described in the multiarch image docs](https://hub.docker.com/r/multiarch/multiarch/debian-debootstrap/)
22+
You can run the multiarch images on an amd64 development system if you [enable binfmt-support as described in the multiarch image docs](https://hub.docker.com/r/multiarch/debian-debootstrap/)
2123

2224
`docker run --rm --privileged multiarch/qemu-user-static:register --reset`

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v5.2.1
1+
v5.2.2

bash_functions.sh

+2-42
Original file line numberDiff line numberDiff line change
@@ -66,43 +66,6 @@ validate_env() {
6666
fi;
6767
}
6868

69-
setup_dnsmasq_dns() {
70-
. /opt/pihole/webpage.sh
71-
local DNS1="${1:-8.8.8.8}"
72-
local DNS2="${2:-8.8.4.4}"
73-
local dnsType='default'
74-
if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then
75-
dnsType='custom'
76-
fi;
77-
78-
# TODO With the addition of this to /start.sh this needs a refactor
79-
if [ ! -f /.piholeFirstBoot ] ; then
80-
local setupDNS1="$(grep 'PIHOLE_DNS_1' ${setupVars})"
81-
local setupDNS2="$(grep 'PIHOLE_DNS_2' ${setupVars})"
82-
setupDNS1="${setupDNS1/PIHOLE_DNS_1=/}"
83-
setupDNS2="${setupDNS2/PIHOLE_DNS_2=/}"
84-
if [[ -n "$DNS1" && -n "$setupDNS1" ]] || \
85-
[[ -n "$DNS2" && -n "$setupDNS2" ]] ; then
86-
echo "Docker DNS variables not used"
87-
fi
88-
echo "Existing DNS servers used (${setupDNS1:-unset} & ${setupDNS2:-unset})"
89-
return
90-
fi
91-
92-
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
93-
if [[ -n "$DNS1" && -z "$setupDNS1" ]] ; then
94-
change_setting "PIHOLE_DNS_1" "${DNS1}"
95-
fi
96-
if [[ -n "$DNS2" && -z "$setupDNS2" ]] ; then
97-
if [[ "$DNS2" == "no" ]] ; then
98-
delete_setting "PIHOLE_DNS_2"
99-
unset PIHOLE_DNS_2
100-
else
101-
change_setting "PIHOLE_DNS_2" "${DNS2}"
102-
fi
103-
fi
104-
}
105-
10669
setup_dnsmasq_interface() {
10770
local interface="${1:-eth0}"
10871
local interfaceType='default'
@@ -129,13 +92,10 @@ setup_dnsmasq_config_if_missing() {
12992
}
13093

13194
setup_dnsmasq() {
132-
local dns1="$1"
133-
local dns2="$2"
134-
local interface="$3"
135-
local dnsmasq_listening_behaviour="$4"
95+
local interface="$1"
96+
local dnsmasq_listening_behaviour="$2"
13697
# Coordinates
13798
setup_dnsmasq_config_if_missing
138-
setup_dnsmasq_dns "$dns1" "$dns2"
13999
setup_dnsmasq_interface "$interface"
140100
setup_dnsmasq_listening_behaviour "$dnsmasq_listening_behaviour"
141101
setup_dnsmasq_user "${DNSMASQ_USER}"

build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ x-common-args: &common-args
55
PIHOLE_VERSION: ${PIHOLE_VERSION}
66
NAME: pihole/pihole
77
MAINTAINER: [email protected]
8-
S6_VERSION: v1.22.1.0
8+
S6_VERSION: v2.1.0.2
99
PHP_ENV_CONFIG: /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
1010
PHP_ERROR_LOG: /var/log/lighttpd/error.log
1111

docker-pi-hole.cron

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
2222
# Download any updates from the adlists
2323
59 1 * * 7 root PATH="$PATH:/usr/local/bin/" docker exec $DOCKER_NAME pihole updateGravity > /dev/null
2424

25-
# Update docker-pi-hole by pulling the latest docker image ane re-creating your container.
25+
# Update docker-pi-hole by pulling the latest docker image and re-creating your container.
2626
# pihole software update commands are unsupported in docker!
2727
#30 2 * * 7 root PATH="$PATH:/usr/local/bin/" docker exec $DOCKER_NAME pihole updatePihole > /dev/null
2828

start.sh

+58-20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export CONDITIONAL_FORWARDING_REVERSE
2828
export TEMPERATUREUNIT
2929
export ADMIN_EMAIL
3030
export WEBUIBOXEDLAYOUT
31+
export QUERY_LOGGING
32+
export PIHOLE_DNS_
3133

3234
export adlistFile='/etc/pihole/adlists.list'
3335

@@ -54,35 +56,71 @@ load_web_password_secret
5456
generate_password
5557
validate_env || exit 1
5658
prepare_configs
57-
change_setting "PIHOLE_INTERFACE" "$PIHOLE_INTERFACE"
58-
change_setting "IPV4_ADDRESS" "$IPV4_ADDRESS"
59-
change_setting "QUERY_LOGGING" "$QUERY_LOGGING"
60-
change_setting "INSTALL_WEB_SERVER" "$INSTALL_WEB_SERVER"
61-
change_setting "INSTALL_WEB_INTERFACE" "$INSTALL_WEB_INTERFACE"
62-
change_setting "LIGHTTPD_ENABLED" "$LIGHTTPD_ENABLED"
63-
change_setting "IPV4_ADDRESS" "$ServerIP"
64-
change_setting "IPV6_ADDRESS" "$ServerIPv6"
65-
change_setting "DNS_BOGUS_PRIV" "$DNS_BOGUS_PRIV"
66-
change_setting "DNS_FQDN_REQUIRED" "$DNS_FQDN_REQUIRED"
67-
change_setting "DNSSEC" "$DNSSEC"
68-
change_setting "REV_SERVER" "$REV_SERVER"
69-
change_setting "REV_SERVER_DOMAIN" "$REV_SERVER_DOMAIN"
70-
change_setting "REV_SERVER_TARGET" "$REV_SERVER_TARGET"
71-
change_setting "REV_SERVER_CIDR" "$REV_SERVER_CIDR"
59+
60+
[ -n "${PIHOLE_INTERFACE}" ] && change_setting "PIHOLE_INTERFACE" "$PIHOLE_INTERFACE"
61+
[ -n "${IPV4_ADDRESS}" ] && change_setting "IPV4_ADDRESS" "$IPV4_ADDRESS"
62+
[ -n "${QUERY_LOGGING}" ] && change_setting "QUERY_LOGGING" "$QUERY_LOGGING"
63+
[ -n "${INSTALL_WEB_SERVER}" ] && change_setting "INSTALL_WEB_SERVER" "$INSTALL_WEB_SERVER"
64+
[ -n "${INSTALL_WEB_INTERFACE}" ] && change_setting "INSTALL_WEB_INTERFACE" "$INSTALL_WEB_INTERFACE"
65+
[ -n "${LIGHTTPD_ENABLED}" ] && change_setting "LIGHTTPD_ENABLED" "$LIGHTTPD_ENABLED"
66+
[ -n "${ServerIP}" ] && change_setting "IPV4_ADDRESS" "$ServerIP"
67+
[ -n "${ServerIPv6}" ] && change_setting "IPV6_ADDRESS" "$ServerIPv6"
68+
[ -n "${DNS_BOGUS_PRIV}" ] && change_setting "DNS_BOGUS_PRIV" "$DNS_BOGUS_PRIV"
69+
[ -n "${DNS_FQDN_REQUIRED}" ] && change_setting "DNS_FQDN_REQUIRED" "$DNS_FQDN_REQUIRED"
70+
[ -n "${DNSSEC}" ] && change_setting "DNSSEC" "$DNSSEC"
71+
[ -n "${REV_SERVER}" ] && change_setting "REV_SERVER" "$REV_SERVER"
72+
[ -n "${REV_SERVER_DOMAIN}" ] && change_setting "REV_SERVER_DOMAIN" "$REV_SERVER_DOMAIN"
73+
[ -n "${REV_SERVER_TARGET}" ] && change_setting "REV_SERVER_TARGET" "$REV_SERVER_TARGET"
74+
[ -n "${REV_SERVER_CIDR}" ] && change_setting "REV_SERVER_CIDR" "$REV_SERVER_CIDR"
75+
7276
if [ -z "$REV_SERVER" ];then
7377
# If the REV_SERVER* variables are set, then there is no need to add these.
7478
# If it is not set, then adding these variables is fine, and they will be converted by the Pi-hole install script
75-
change_setting "CONDITIONAL_FORWARDING" "$CONDITIONAL_FORWARDING"
76-
change_setting "CONDITIONAL_FORWARDING_IP" "$CONDITIONAL_FORWARDING_IP"
77-
change_setting "CONDITIONAL_FORWARDING_DOMAIN" "$CONDITIONAL_FORWARDING_DOMAIN"
78-
change_setting "CONDITIONAL_FORWARDING_REVERSE" "$CONDITIONAL_FORWARDING_REVERSE"
79+
[ -n "${CONDITIONAL_FORWARDING}" ] && change_setting "CONDITIONAL_FORWARDING" "$CONDITIONAL_FORWARDING"
80+
[ -n "${CONDITIONAL_FORWARDING_IP}" ] && change_setting "CONDITIONAL_FORWARDING_IP" "$CONDITIONAL_FORWARDING_IP"
81+
[ -n "${CONDITIONAL_FORWARDING_DOMAIN}" ] && change_setting "CONDITIONAL_FORWARDING_DOMAIN" "$CONDITIONAL_FORWARDING_DOMAIN"
82+
[ -n "${CONDITIONAL_FORWARDING_REVERSE}" ] && change_setting "CONDITIONAL_FORWARDING_REVERSE" "$CONDITIONAL_FORWARDING_REVERSE"
83+
fi
84+
85+
if [ -z "${PIHOLE_DNS_}" ]; then
86+
# For backward compatibility, if DNS1 and/or DNS2 are set, but PIHOLE_DNS_ is not, convert them to
87+
# a semi-colon delimited string and store in PIHOLE_DNS_
88+
# They are not used anywhere if PIHOLE_DNS_ is set already
89+
[ -n "${DNS1}" ] && echo "Converting DNS1 to PIHOLE_DNS_" && PIHOLE_DNS_="$DNS1"
90+
[[ -n "${DNS2}" && "${DNS2}" != "no" ]] && echo "Converting DNS2 to PIHOLE_DNS_" && PIHOLE_DNS_="$PIHOLE_DNS_;$DNS2"
7991
fi
92+
93+
# Parse the PIHOLE_DNS variable, if it exists, and apply upstream servers to Pi-hole config
94+
if [ -n "${PIHOLE_DNS_}" ]; then
95+
echo "Setting DNS servers based on PIHOLE_DNS_ variable"
96+
# Split into an array (delimited by ;)
97+
PIHOLE_DNS_ARR=(${PIHOLE_DNS_//;/ })
98+
count=1
99+
for i in "${PIHOLE_DNS_ARR[@]}"; do
100+
change_setting "PIHOLE_DNS_$count" "$i"
101+
((count=count+1))
102+
done
103+
else
104+
# Environment variable has not been set, but there may be existing values in an existing setupVars.conf
105+
# if this is the case, we do not want to overwrite these with the defaults of 8.8.8.8 and 8.8.4.4
106+
# Pi-hole can run with only one upstream configured, so we will just check for one.
107+
setupVarsDNS="$(grep 'PIHOLE_DNS_' /etc/pihole/setupVars.conf || true)"
108+
109+
if [ -z "${setupVarsDNS}" ]; then
110+
echo "Configuring default DNS servers: 8.8.8.8, 8.8.4.4"
111+
change_setting "PIHOLE_DNS_1" "8.8.8.8"
112+
change_setting "PIHOLE_DNS_2" "8.8.4.4"
113+
else
114+
echo "Existing DNS servers detected in setupVars.conf. Leaving them alone"
115+
fi
116+
fi
117+
80118
setup_web_port "$WEB_PORT"
81119
setup_web_password "$WEBPASSWORD"
82120
setup_temp_unit "$TEMPERATUREUNIT"
83121
setup_ui_layout "$WEBUIBOXEDLAYOUT"
84122
setup_admin_email "$ADMIN_EMAIL"
85-
setup_dnsmasq "$DNS1" "$DNS2" "$INTERFACE" "$DNSMASQ_LISTENING_BEHAVIOUR"
123+
setup_dnsmasq "$INTERFACE" "$DNSMASQ_LISTENING_BEHAVIOUR"
86124
setup_php_env
87125
setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME"
88126
setup_ipv4_ipv6

0 commit comments

Comments
 (0)