diff --git a/README.md b/README.md index 3e79a9e..1751c4a 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,6 @@ services: volumes: - './etc-pihole/:/etc/pihole/' - './etc-dnsmasq.d/:/etc/dnsmasq.d/' - dns: - - 127.0.0.1 - - 1.1.1.1 # Recommended but not required (DHCP needs NET_ADMIN) # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: diff --git a/bash_functions.sh b/bash_functions.sh index 62183f7..32a0d32 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -2,31 +2,6 @@ # Some of the bash_functions use variables these core pi-hole/web scripts . /opt/pihole/webpage.sh -docker_checks() { - 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 -} - fix_capabilities() { setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN+ei $(which pihole-FTL) || ret=$? diff --git a/docker-compose-jwilder-proxy.yml b/docker-compose-jwilder-proxy.yml index 47ab2f7..ee9c9e4 100644 --- a/docker-compose-jwilder-proxy.yml +++ b/docker-compose-jwilder-proxy.yml @@ -15,9 +15,6 @@ services: pihole: image: pihole/pihole:latest - dns: - - 127.0.0.1 - - 1.1.1.1 ports: - '53:53/tcp' - '53:53/udp' @@ -60,4 +57,4 @@ services: # PROXY_LOCATION: ghost # VIRTUAL_HOST: ghost.yourDomain.lan # VIRTUAL_PORT: 2368 -# restart: always \ No newline at end of file +# restart: always diff --git a/docker-compose-traefik-proxy.md b/docker-compose-traefik-proxy.md index 4b8c034..48e7662 100644 --- a/docker-compose-traefik-proxy.md +++ b/docker-compose-traefik-proxy.md @@ -51,9 +51,6 @@ services: image: pihole/pihole:latest networks: - discovery - dns: - - 127.0.0.1 - - 1.1.1.1 ports: - '0.0.0.0:53:53/tcp' - '0.0.0.0:53:53/udp' diff --git a/docker-compose.yml b/docker-compose.yml index 06cd155..031eb49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,9 +22,6 @@ services: - './etc-dnsmasq.d/:/etc/dnsmasq.d/' # run `touch ./var-log/pihole.log` first unless you like errors # - './var-log/pihole.log:/var/log/pihole.log' - dns: - - 127.0.0.1 - - 1.1.1.1 # Recommended but not required (DHCP needs NET_ADMIN) # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: diff --git a/start.sh b/start.sh index 85cf711..16b8c79 100755 --- a/start.sh +++ b/start.sh @@ -38,8 +38,6 @@ PH_TEST=true . $PIHOLE_INSTALL echo " ::: Starting docker specific checks & setup for docker pihole/pihole" -docker_checks - # TODO: #if [ ! -f /.piholeFirstBoot ] ; then # echo " ::: Not first container startup so not running docker's setup, re-create container to run setup again" diff --git a/test/conftest.py b/test/conftest.py index 6ff8b44..bb82273 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,6 +2,7 @@ import functools import os import pytest +import subprocess import testinfra import types @@ -15,8 +16,22 @@ with open('{}/VERSION'.format(dotdot), 'r') as v: __version__ = raw_version.replace('release/', 'release-') @pytest.fixture() -def args_dns(): - return '--dns 127.0.0.1 --dns 1.1.1.1' +def run_and_stream_command_output(): + def run_and_stream_command_output_inner(command, verbose=False): + print("Running", command) + build_env = os.environ.copy() + build_env['PIHOLE_VERSION'] = __version__ + build_result = subprocess.Popen(command.split(), env=build_env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + bufsize=1, universal_newlines=True) + if verbose: + while build_result.poll() is None: + for line in build_result.stdout: + print(line, end='') + build_result.wait() + if build_result.returncode != 0: + print(" ::: Error running".format(command)) + print(build_result.stderr) + return run_and_stream_command_output_inner @pytest.fixture() def args_volumes(): @@ -27,8 +42,8 @@ def args_env(): return '-e ServerIP="127.0.0.1"' @pytest.fixture() -def args(args_dns, args_volumes, args_env): - return "{} {} {}".format(args_dns, args_volumes, args_env) +def args(args_volumes, args_env): + return "{} {}".format(args_volumes, args_env) @pytest.fixture() def test_args(): @@ -123,8 +138,8 @@ def persist_args_env(): return '-e ServerIP="127.0.0.1"' @pytest.fixture(scope='module') -def persist_args(persist_args_dns, persist_args_volumes, persist_args_env): - return "{} {} {}".format(args_dns, args_volumes, args_env) +def persist_args(persist_args_volumes, persist_args_env): + return "{} {}".format(persist_args_volumes, persist_args_env) @pytest.fixture(scope='module') def persist_test_args(): diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index d917a50..8773d41 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -179,20 +179,3 @@ def test_webPassword_pre_existing_trumps_all_envs(Docker, args_env, test_args): assert '::: Pre existing WEBPASSWORD found' in function.stdout assert Docker.run('grep -q \'{}\' {}'.format('WEBPASSWORD=volumepass', '/etc/pihole/setupVars.conf')).rc == 0 - - -@pytest.mark.skip('broke, needs investigation in v5.0 beta') -@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 diff --git a/test/test_volume_data.sh b/test/test_volume_data.sh index 97a71ce..de854b6 100755 --- a/test/test_volume_data.sh +++ b/test/test_volume_data.sh @@ -8,9 +8,12 @@ set -ex # Debug can be added anywhere to check current state mid-test RED='\033[0;31m' NC='\033[0m' # No Color +if [ $(id -u) != 0 ] ; then + sudo=sudo # do not need if root (in docker) +fi debug() { - sudo grep -r . "$VOL_PH" - sudo grep -r . "$VOL_DM" + $sudo grep -r . "$VOL_PH" + $sudo grep -r . "$VOL_DM" } # Cleanup at the end, print debug on fail cleanup() { @@ -21,7 +24,7 @@ cleanup() { debug fi docker rm -f $CONTAINER - sudo rm -rf $VOLUMES + $sudo rm -rf $VOLUMES exit $retcode } trap "cleanup" INT TERM EXIT diff --git a/test/test_volumes.py b/test/test_volumes.py index d703bf1..1207f27 100644 --- a/test/test_volumes.py +++ b/test/test_volumes.py @@ -1,25 +1,4 @@ -import subprocess - -def run_and_stream_command_output(command, verbose=False): - print("Running", command) - build_env = os.environ.copy() - build_env['PIHOLE_VERSION'] = __version__ - build_result = subprocess.Popen(command.split(), env=build_env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - bufsize=1, universal_newlines=True) - if verbose: - while build_result.poll() is None: - for line in build_result.stdout: - print(line, end='') - build_result.wait() - if build_result.returncode != 0: - print(" ::: Error running".format(command)) - print(build_result.stderr) - -def test_volume_shell_script(arch): +def test_volume_shell_script(arch, run_and_stream_command_output): # only one arch should be necessary if arch == 'amd64': run_and_stream_command_output('./test/test_volume_data.sh') - - -def test_fail(): - assert 1 == 2