diff --git a/README.md b/README.md index 5283122..e71db63 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ There are other environment variables if you want to customize various things in | `-e TZ=`
**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. | `-e WEBPASSWORD=`
**Recommended** *Default: random* | http://pi.hole/admin password. Run `docker logs pihole \| grep random` to find your random pass. | `-e DNS1=`
*Optional* *Default: 8.8.8.8* | Primary upstream DNS provider, default is google DNS -| `-e DNS2=`
*Optional* *Default: 8.8.4.4* | Secondary upstream DNS provider, default is google DNS +| `-e DNS2=`
*Optional* *Default: 8.8.4.4* | Secondary upstream DNS provider, default is google DNS, `no` if only one DNS should used | `-e VIRTUAL_HOST=`
*Optional* *Default: $ServerIP* | What your web server 'virtual host' is, accessing admin through this Hostname/IP allows you to make changes to the whitelist / blacklists in addition to the default 'http://pi.hole/admin/' address | `-e IPv6=`
*Optional* *Default: True* | For unraid compatibility, strips out all the IPv6 configuration from DNS/Web services when false. | `-e INTERFACE=`
*Advanced/Optional* | The default works fine with our basic example docker run commands. If you're trying to use DHCP with `--net host` mode then you may have to customize this or DNSMASQ_LISTENING. diff --git a/bash_functions.sh b/bash_functions.sh index 710ae42..14a05e3 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -63,7 +63,11 @@ setup_dnsmasq_dns() { change_setting "PIHOLE_DNS_1" "${DNS1}" fi if [[ -n "$DNS2" && -z "$setupDNS2" ]] ; then - change_setting "PIHOLE_DNS_2" "${DNS2}" + if [ "$DNS2" = "no" ] ; then + delete_setting "PIHOLE_DNS_2" + else + change_setting "PIHOLE_DNS_2" "${DNS2}" + fi fi } diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index a35776a..c744fc3 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -55,6 +55,8 @@ def test_bad_input_to_WEB_PORT(Docker, args, expected_error): ('-e ServerIP="1.2.3.4" -e DNS1="1.2.3.4"', 'custom DNS', '1.2.3.4', '8.8.4.4' ), ('-e ServerIP="1.2.3.4" -e DNS2="1.2.3.4"', 'custom DNS', '8.8.8.8', '1.2.3.4' ), ('-e ServerIP="1.2.3.4" -e DNS1="1.2.3.4" -e DNS2="2.2.3.4"', 'custom DNS', '1.2.3.4', '2.2.3.4' ), + ('-e ServerIP="1.2.3.4" -e DNS1="1.2.3.4" -e DNS2="no"', 'custom DNS', '1.2.3.4', None ), + ('-e ServerIP="1.2.3.4" -e DNS2="no"', 'custom DNS', '8.8.8.8', None ), ]) def test_override_default_servers_with_DNS_EnvVars(Docker, args, expected_stdout, dns1, dns2): ''' on first boot when DNS vars are NOT set explain default google DNS settings are used @@ -64,7 +66,7 @@ def test_override_default_servers_with_DNS_EnvVars(Docker, args, expected_stdout assert expected_stdout in function.stdout docker_dns_servers = Docker.run('grep "^server=" /etc/dnsmasq.d/01-pihole.conf').stdout - expected_servers = 'server={}\nserver={}\n'.format(dns1, dns2) + expected_servers = 'server={}\n'.format(dns1) if dns2 == None else 'server={}\nserver={}\n'.format(dns1, dns2) assert expected_servers == docker_dns_servers @pytest.mark.parametrize('args, dns1, dns2, expected_stdout', [