diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..adf19fc --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Docker Pi-Hole changelog + +Notes about releases will be documented on [docker-pi-hole's github releases page](https://github.com/pi-hole/docker-pi-hole/releases). Breaking changes will be copied to the top of the docker repo's README file to assist with common upgrade issues. + +See the [Pi-hole releases](https://github.com/pi-hole/pi-hole/releases) for details on updates unreleated to docker image releases diff --git a/README.md b/README.md index ece1747..2d35389 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Starting with the v4.1.1 release your Pi-hole container may encounter issues sta - `--cap-add=NET_ADMIN` This previously optional argument is now required or strongly encouraged - Starting in version 4.1.2 FTL, the DNS Service, is going to check this setting automatically - `--dns=127.0.0.1 --dns=1.1.1.1` The second server can be any DNS IP of your choosing, but the **first dns must be 127.0.0.1** - - A WARNING stating "resolv.conf misconfiguration, see v4.1.1 release notes" may show in docker logs without this. + - A WARNING stating "Misconfigured DNS in /etc/resolv.conf" may show in docker logs without this. These are the raw [docker run cli](https://docs.docker.com/engine/reference/commandline/cli/) versions of the commands. We provide no official support for docker GUIs but the community forums may be able to help if you do not see a place for these settings. Remember, always consult your manual too! diff --git a/bash_functions.sh b/bash_functions.sh index 3fce8eb..68d0caa 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -1,7 +1,28 @@ #!/bin/bash docker_checks() { - echo hi + warn_msg='WARNING Misconfigured DNS in /etc/resolv.conf' + ns_count="$(grep -c nameserver /etc/resolv.conf)" + ns_primary="$(grep nameserver /etc/resolv.conf | head -1)" + ns_primary="${ns_primary/nameserver /}" + warned=false + + if [ "$ns_count" -lt 2 ] ; then + echo "$warn_msg: Two DNS servers are recommended, 127.0.0.1 and any backup server" + warned=true + fi + + if [ "$ns_primary" != "127.0.0.1" ] ; then + echo "$warn_msg: Primary DNS should be 127.0.0.1 (found ${ns_primary})" + warned=true + fi + + if ! $warned ; then + echo "OK: Checks passed for /etc/resolv.conf DNS servers" + fi + + echo + cat /etc/resolv.conf } prepare_configs() { diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index b314ef3..2460b7d 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -179,5 +179,17 @@ def test_webPassword_env_assigns_password_to_file_or_removes_if_empty(Docker, ar -def test_docker_checks_for_resolvconf_misconfiguration(Docker): - pass +@pytest.mark.parametrize('args_dns, expected_stdout', [ + # No DNS passed will vary by the host this is ran on, bad idea for a test + #('', 'WARNING Misconfigured DNS in /etc/resolv.conf: Primary DNS should be 127.0.0.1'), + ('--dns 1.1.1.1', 'WARNING Misconfigured DNS in /etc/resolv.conf: Two DNS servers are recommended, 127.0.0.1 and any backup server\n' + 'WARNING Misconfigured DNS in /etc/resolv.conf: Primary DNS should be 127.0.0.1 (found 1.1.1.1)'), + ('--dns 127.0.0.1', 'WARNING Misconfigured DNS in /etc/resolv.conf: Two DNS servers are recommended, 127.0.0.1 and any backup server'), + ('--dns 1.1.1.1 --dns 127.0.0.1', 'WARNING Misconfigured DNS in /etc/resolv.conf: Primary DNS should be 127.0.0.1 (found 1.1.1.1)'), + ('--dns 127.0.0.1 --dns 1.1.1.1', 'OK: Checks passed for /etc/resolv.conf DNS servers'), +]) +def test_docker_checks_for_resolvconf_misconfiguration(Docker, args_dns, expected_stdout): + ''' The container checks for misconfigured resolv.conf ''' + function = Docker.run('. /bash_functions.sh ; eval `grep docker_checks /start.sh`') + print function.stdout + assert expected_stdout in function.stdout