From 800972856ea46dfbf8634c99b6391ce76e07f2cf Mon Sep 17 00:00:00 2001 From: diginc Date: Mon, 13 Nov 2017 20:41:49 -0600 Subject: [PATCH 1/5] Added development branch source to test upcoming releases --- Dockerfile.py | 8 +++----- install.sh | 19 +++++++++++-------- tox.ini | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Dockerfile.py b/Dockerfile.py index 8188c42..e1fd9ac 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -117,12 +117,10 @@ def build(docker_repo, os, arch, args): dockerfile = 'Dockerfile_{}_{}'.format(os, arch) repo_tag = '{}:{}_{}'.format(docker_repo, os, arch) - print " ::: Pulling {} to reuse layers".format(dockerfile, repo_tag) - pull_cmd = run_local('docker pull {}/{}'.format('diginc', repo_tag)) - if args['-v']: - print pull_cmd.stdout + cached_image = '{}/{}'.format('diginc', repo_tag) print " ::: Building {} into {}".format(dockerfile, repo_tag) - build_cmd = run_local('docker build --pull -f {} -t {} .'.format(dockerfile, repo_tag)) + build_cmd = run_local('docker build --pull --cache-from="{cache},{create_tag}" -f {dockerfile} -t {create_tag} .'\ + .format(cache=cached_image, dockerfile=dockerfile, create_tag=repo_tag)) if args['-v']: print build_cmd.stdout if build_cmd.rc != 0: diff --git a/install.sh b/install.sh index 9597687..7d1e676 100755 --- a/install.sh +++ b/install.sh @@ -1,8 +1,9 @@ #!/bin/bash -ex mkdir -p /etc/pihole/ -export CORE_TAG='v3.1.4' +export CORE_TAG='development' export WEB_TAG='v3.1' export FTL_TAG='v2.11.1' +export USE_DEVELOPMENT_BRANCHES=true # Make pihole scripts fail searching for `systemctl`, # which fails pretty miserably in docker compared to `service` @@ -59,9 +60,14 @@ piholeGitUrl="${piholeGitUrl}" webInterfaceGitUrl="${webInterfaceGitUrl}" webInterfaceDir="${webInterfaceDir}" git clone "${piholeGitUrl}" "${PI_HOLE_LOCAL_REPO}" -pushd "${PI_HOLE_LOCAL_REPO}"; git reset --hard "${CORE_TAG}"; popd; git clone "${webInterfaceGitUrl}" "${webInterfaceDir}" -pushd "${webInterfaceDir}"; git reset --hard "${WEB_TAG}"; popd; +if [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then + pushd "${PI_HOLE_LOCAL_REPO}"; git checkout development; popd; + pushd "${webInterfaceDir}"; git checkout devel; popd; +else + pushd "${PI_HOLE_LOCAL_REPO}"; git reset --hard "${CORE_TAG}"; popd; + pushd "${webInterfaceDir}"; git reset --hard "${WEB_TAG}"; popd; +fi export PIHOLE_INTERFACE=eth0 export IPV4_ADDRESS=0.0.0.0 @@ -70,8 +76,8 @@ export PIHOLE_DNS_1=8.8.8.8 export PIHOLE_DNS_2=8.8.4.4 export QUERY_LOGGING=true -tmpLog="${tmpLog}" -instalLogLoc="${instalLogLoc}" +tmpLog="/tmp/pihole-install.log" +installLogLoc="${installLogLoc}" installPihole | tee "${tmpLog}" sed -i 's/readonly //g' /opt/pihole/webpage.sh if [[ "$TAG" == 'alpine' ]] ; then @@ -84,9 +90,6 @@ if [[ "$TAG" == 'alpine' ]] ; then sed -i "s/\$_SERVER\['SERVER_NAME'\]/\$_SERVER\['HTTP_HOST'\]/" /var/www/html/pihole/index.php fi - -mv "${tmpLog}" "${instalLogLoc}" - # Fix dnsmasq in docker grep -q '^user=root' || echo -e '\nuser=root' >> /etc/dnsmasq.conf echo 'Docker install successful' diff --git a/tox.ini b/tox.ini index aec61dd..75134c9 100644 --- a/tox.ini +++ b/tox.ini @@ -5,5 +5,5 @@ envlist = py27 whitelist_externals = docker deps = -rrequirements.txt commands = docker run --rm --privileged multiarch/qemu-user-static:register --reset - ./Dockerfile.py + ./Dockerfile.py -v pytest {posargs:-vv -n auto} ./test/ From 6ff1d21f7b7c3cc348f262b9a1009393ce2f4035 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 7 Dec 2017 19:57:09 -0600 Subject: [PATCH 2/5] New s6 version, remove old list.sh --- Dockerfile.py | 2 +- Dockerfile_alpine_amd64 | 2 +- Dockerfile_alpine_armhf | 2 +- Dockerfile_debian_aarch64 | 2 +- Dockerfile_debian_amd64 | 2 +- Dockerfile_debian_armhf | 2 +- s6/alpine-root/usr/bin/list.sh | 235 --------------------------------- 7 files changed, 6 insertions(+), 241 deletions(-) delete mode 100755 s6/alpine-root/usr/bin/list.sh diff --git a/Dockerfile.py b/Dockerfile.py index 213c675..8c46af5 100755 --- a/Dockerfile.py +++ b/Dockerfile.py @@ -27,7 +27,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__)) base_vars = { 'name': 'diginc/pi-hole', 'maintainer' : 'adam@diginc.us', - 's6_version' : 'v1.20.0.0', + 's6_version' : 'v1.21.2.1', } os_base_vars = { diff --git a/Dockerfile_alpine_amd64 b/Dockerfile_alpine_amd64 index 236c174..aedc537 100644 --- a/Dockerfile_alpine_amd64 +++ b/Dockerfile_alpine_amd64 @@ -11,7 +11,7 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-amd64.tar.gz # TODO Re-enable upgrade after php5 packages use the latest greatest libressl packages, conflicts are breaking build 2017-11-14 # RUN apk upgrade --update && \ diff --git a/Dockerfile_alpine_armhf b/Dockerfile_alpine_armhf index 78c1b2b..e111693 100644 --- a/Dockerfile_alpine_armhf +++ b/Dockerfile_alpine_armhf @@ -11,7 +11,7 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-armhf.tar.gz # TODO Re-enable upgrade after php5 packages use the latest greatest libressl packages, conflicts are breaking build 2017-11-14 # RUN apk upgrade --update && \ diff --git a/Dockerfile_debian_aarch64 b/Dockerfile_debian_aarch64 index 33caa7d..f8643e3 100644 --- a/Dockerfile_debian_aarch64 +++ b/Dockerfile_debian_aarch64 @@ -11,7 +11,7 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-aarch64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-aarch64.tar.gz RUN apt-get update && \ apt-get install -y wget curl net-tools cron && \ diff --git a/Dockerfile_debian_amd64 b/Dockerfile_debian_amd64 index 3600d64..a4b744a 100644 --- a/Dockerfile_debian_amd64 +++ b/Dockerfile_debian_amd64 @@ -11,7 +11,7 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-amd64.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-amd64.tar.gz RUN apt-get update && \ apt-get install -y wget curl net-tools cron && \ diff --git a/Dockerfile_debian_armhf b/Dockerfile_debian_armhf index e19eecb..c74acbe 100644 --- a/Dockerfile_debian_armhf +++ b/Dockerfile_debian_armhf @@ -11,7 +11,7 @@ ENV PATH /opt/pihole:${PATH} COPY install.sh /usr/local/bin/docker-install.sh ENV setupVars /etc/pihole/setupVars.conf ENV PIHOLE_INSTALL /tmp/ph_install.sh -ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-armhf.tar.gz +ENV S6OVERLAY_RELEASE https://github.com/just-containers/s6-overlay/releases/download/v1.21.2.1/s6-overlay-armhf.tar.gz RUN apt-get update && \ apt-get install -y wget curl net-tools cron && \ diff --git a/s6/alpine-root/usr/bin/list.sh b/s6/alpine-root/usr/bin/list.sh deleted file mode 100755 index 36e836b..0000000 --- a/s6/alpine-root/usr/bin/list.sh +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env bash -# Pi-hole: A black hole for Internet advertisements -# (c) 2017 Pi-hole, LLC (https://pi-hole.net) -# Network-wide ad blocking via your own hardware. -# -# Whitelists and blacklists domains -# -# This file is copyright under the latest version of the EUPL. -# Please see LICENSE file for your rights under this license. - - - -#globals -basename=pihole -piholeDir=/etc/${basename} -whitelist=${piholeDir}/whitelist.txt -blacklist=${piholeDir}/blacklist.txt -readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf" -reload=false -addmode=true -verbose=true - -domList=() -domToRemoveList=() - -listMain="" -listAlt="" - -helpFunc() { - - if [[ ${listMain} == ${whitelist} ]]; then - letter="w" - word="white" - else - letter="b" - word="black" - fi - - cat << EOM -::: Immediately ${word}lists one or more domains in the hosts file -::: -::: Usage: pihole -${letter} domain1 [domain2 ...] -::: -::: Options: -::: -d, --delmode Remove domains from the ${word}list -::: -nr, --noreload Update ${word}list without refreshing dnsmasq -::: -q, --quiet Output is less verbose -::: -h, --help Show this help dialog -::: -l, --list Display your ${word}listed domains -EOM -if [[ "${letter}" == "b" ]]; then - echo "::: -wild, --wildcard Add wildcard entry (only blacklist)" -fi - exit 0 -} - -EscapeRegexp() { - # This way we may safely insert an arbitrary - # string in our regular expressions - # Also remove leading "." if present - echo $* | sed 's/^\.*//' | sed "s/[]\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g" -} - -HandleOther(){ - # First, convert everything to lowercase - domain=$(sed -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" <<< "$1") - - #check validity of domain - validDomain=$(echo "${domain}" | perl -lne 'print if /(?!.*[^a-z0-9-\.].*)^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9-]+\.)*[a-z]{2,63}/') - if [ -z "${validDomain}" ]; then - echo "::: $1 is not a valid argument or domain name" - else - domList=("${domList[@]}" ${validDomain}) - fi -} - -PoplistFile() { - #check whitelist file exists, and if not, create it - if [[ ! -f ${whitelist} ]]; then - touch ${whitelist} - fi - for dom in "${domList[@]}"; do - # Logic : If addmode then add to desired list and remove from the other; if delmode then remove from desired list but do not add to the other - if ${addmode}; then - AddDomain "${dom}" "${listMain}" - RemoveDomain "${dom}" "${listAlt}" - if [[ "${listMain}" == "${whitelist}" || "${listMain}" == "${blacklist}" ]]; then - RemoveDomain "${dom}" "${wildcardlist}" - fi - else - RemoveDomain "${dom}" "${listMain}" - fi - done -} - -AddDomain() { - list="$2" - domain=$(EscapeRegexp "$1") - - if [[ "${list}" == "${whitelist}" || "${list}" == "${blacklist}" ]]; then - - bool=true - #Is the domain in the list we want to add it to? - grep -Ex -q "${domain}" "${list}" > /dev/null 2>&1 || bool=false - - if [[ "${bool}" == false ]]; then - #domain not found in the whitelist file, add it! - if [[ "${verbose}" == true ]]; then - echo "::: Adding $1 to $list..." - fi - reload=true - # Add it to the list we want to add it to - echo "$1" >> "${list}" - else - if [[ "${verbose}" == true ]]; then - echo "::: ${1} already exists in ${list}, no need to add!" - fi - fi - - elif [[ "${list}" == "${wildcardlist}" ]]; then - - source "${piholeDir}/setupVars.conf" - #Remove the /* from the end of the IPv4addr. - IPV4_ADDRESS=${IPV4_ADDRESS%/*} - IPV6_ADDRESS=${IPV6_ADDRESS} - - bool=true - #Is the domain in the list? - grep -e "address=\/${domain}\/" "${wildcardlist}" > /dev/null 2>&1 || bool=false - - if [[ "${bool}" == false ]]; then - if [[ "${verbose}" == true ]]; then - echo "::: Adding $1 to wildcard blacklist..." - fi - reload=true - echo "address=/$1/${IPV4_ADDRESS}" >> "${wildcardlist}" - if [[ ${#IPV6_ADDRESS} > 0 ]] ; then - echo "address=/$1/${IPV6_ADDRESS}" >> "${wildcardlist}" - fi - else - if [[ "${verbose}" == true ]]; then - echo "::: ${1} already exists in wildcard blacklist, no need to add!" - fi - fi - fi -} - -RemoveDomain() { - list="$2" - domain=$(EscapeRegexp "$1") - - if [[ "${list}" == "${whitelist}" || "${list}" == "${blacklist}" ]]; then - - bool=true - #Is it in the list? Logic follows that if its whitelisted it should not be blacklisted and vice versa - grep -Ex -q "${domain}" "${list}" > /dev/null 2>&1 || bool=false - if [[ "${bool}" == true ]]; then - # Remove it from the other one - echo "::: Removing $1 from $list..." - # Busybox sed compatible case-insensitive domain removal - sed -i "$(grep -in "^${domain}$" ${list} | awk -F':' '{print $1}' | tr '\n' ',' | sed 's/,$/\n/')d" ${list} - reload=true - else - if [[ "${verbose}" == true ]]; then - echo "::: ${1} does not exist in ${list}, no need to remove!" - fi - fi - - elif [[ "${list}" == "${wildcardlist}" ]]; then - - bool=true - #Is it in the list? - grep -e "address=\/${domain}\/" "${wildcardlist}" > /dev/null 2>&1 || bool=false - if [[ "${bool}" == true ]]; then - # Remove it from the other one - echo "::: Removing $1 from $list..." - # Busybox sed compatible case-insensitive domain removal - sed -i "$(grep -in "/${domain}/" ${list} | awk -F':' '{print $1}' | tr '\n' ',' | sed 's/,$/\n/')d" ${list} - reload=true - else - if [[ "${verbose}" == true ]]; then - echo "::: ${1} does not exist in ${list}, no need to remove!" - fi - fi - fi -} - -Reload() { - # Reload hosts file - pihole -g -sd -} - -Displaylist() { - if [[ ${listMain} == ${whitelist} ]]; then - string="gravity resistant domains" - else - string="domains caught in the sinkhole" - fi - verbose=false - echo -e " Displaying $string \n" - count=1 - while IFS= read -r RD; do - echo "${count}: ${RD}" - count=$((count+1)) - done < "${listMain}" - exit 0; -} - -for var in "$@"; do - case "${var}" in - "-w" | "whitelist" ) listMain="${whitelist}"; listAlt="${blacklist}";; - "-b" | "blacklist" ) listMain="${blacklist}"; listAlt="${whitelist}";; - "-wild" | "wildcard" ) listMain="${wildcardlist}";; - "-nr"| "--noreload" ) reload=false;; - "-d" | "--delmode" ) addmode=false;; - "-f" | "--force" ) force=true;; - "-q" | "--quiet" ) verbose=false;; - "-h" | "--help" ) helpFunc;; - "-l" | "--list" ) Displaylist;; - * ) HandleOther "${var}";; - esac -done - -shift - -if [[ $# = 0 ]]; then - helpFunc -fi - -PoplistFile - -if ${reload}; then - Reload -fi - From aab0b3f3cb2984523b18c543f30d11a481c11518 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 7 Dec 2017 20:27:06 -0600 Subject: [PATCH 3/5] fix debian test_pihole_start_cmd --- bash_functions.sh | 2 +- install.sh | 2 +- test/conftest.py | 2 +- test/test_pihole_scripts.py | 21 ++++++++++++--------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 5702153..38e59e4 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -276,7 +276,7 @@ test_framework_stubbing() { if [ -n "$PYTEST" ] ; then echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block" sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" - echo 'testblock.pi-hole.local' >> /etc/pihole/blacklist.txt + echo 'testblock.pi-hole.local' >> /etc/pihole/black.list fi } diff --git a/install.sh b/install.sh index f4c526e..7f8cac0 100755 --- a/install.sh +++ b/install.sh @@ -46,7 +46,7 @@ if [[ "$TAG" == 'debian' ]] ; then # IPv6 support for nc openbsd better than traditional apt-get install -y --force-yes netcat-openbsd elif [[ "$TAG" == 'alpine' ]] ; then - apk add \ + apk add -U \ dnsmasq \ nginx \ ca-certificates \ diff --git a/test/conftest.py b/test/conftest.py index b921d4a..613aecc 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -8,7 +8,7 @@ check_output = testinfra.get_backend( def DockerGeneric(request, args, image, cmd): assert 'docker' in check_output('id'), "Are you in the docker group?" if 'pi-hole' in image: - args += " --dns 127.0.0.1 -v /dev/null:/etc/.pihole/adlists.default -e PYTEST=\"True\"" + args += " --dns 127.0.0.1 -v /dev/null:/etc/pihole/adlists.default -e PYTEST=\"True\"" docker_run = "docker run -d {} {} {}".format(args, image, cmd) print docker_run docker_id = check_output(docker_run) diff --git a/test/test_pihole_scripts.py b/test/test_pihole_scripts.py index 372ec07..66cd032 100644 --- a/test/test_pihole_scripts.py +++ b/test/test_pihole_scripts.py @@ -10,6 +10,7 @@ def RunningPiHole(DockerPersist, Slow, persist_webserver, persist_tag, start_cmd ''' Override the RunningPiHole to run and check for success of a dnsmasq start based `pihole` script command ''' #print DockerPersist.run('ps -ef').stdout + assert DockerPersist.dig.run('ping -c 1 test_pihole').rc == 0 Slow(lambda: DockerPersist.run('pgrep dnsmasq').rc == 0) Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver)).rc == 0) oldpid = DockerPersist.run('pidof dnsmasq') @@ -30,15 +31,17 @@ def test_pihole_start_cmd(RunningPiHole, start_cmd, persist_tag): ''' the start_cmd tests are all built into the RunningPiHole fixture in this file ''' assert RunningPiHole.cmd.stdout == START_DNS_STDOUT[persist_tag] -@pytest.mark.parametrize('start_cmd,hostname,expected_ip, expected_message', [ - ('enable', 'pi.hole', '127.0.0.1', 'enabled'), - ('disable 0', 'pi.hole', '127.0.0.1', 'disabled'), +@pytest.mark.parametrize('start_cmd,hostname,expected_ip, expected_messages', [ + ('enable', 'pi.hole', '127.0.0.1', ['Enabling blocking','Pi-hole Enabled']), + ('disable', 'pi.hole', '127.0.0.1', ['Disabling blocking','Pi-hole Disabled']), ]) -def test_pihole_start_cmd(RunningPiHole, Dig, persist_tag, start_cmd, hostname, expected_ip, expected_message): +def test_pihole_start_cmd(RunningPiHole, Dig, persist_tag, start_cmd, hostname, expected_ip, expected_messages): ''' the start_cmd tests are all built into the RunningPiHole fixture in this file ''' - dig_cmd = "dig +time=1 +noall +answer {} @test_pihole | awk '{{ print $5 }}'".format(hostname) - lookup = RunningPiHole.dig.run(dig_cmd).stdout.rstrip('\n') - assert lookup == expected_ip + dig_cmd = "dig +time=1 +noall +answer {} @test_pihole".format(hostname) + lookup = RunningPiHole.dig.run(dig_cmd) + assert lookup.rc == 0 + lookup_ip = lookup.stdout.split()[4] + assert lookup_ip == expected_ip - stdout = "::: Blocking has been {}!\n".format(expected_message) - assert stdout in RunningPiHole.cmd.stdout + for part_of_output in expected_messages: + assert part_of_output in RunningPiHole.cmd.stdout From 988e17be7af45a741c8a6aec0c864727fd689db0 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 7 Dec 2017 23:30:54 -0600 Subject: [PATCH 4/5] some of the debian_amd64 load_as_expected tests fixed, tab2spaces --- bash_functions.sh | 32 +++++++++++++++++--------------- install.sh | 6 +++++- test/test_start.py | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 38e59e4..f6e3f1e 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -63,10 +63,10 @@ setup_dnsmasq_dns() { fi echo "Using $dnsType DNS servers: $DNS1 & $DNS2" - if [[ -n "$DNS1" && -z "$setupDNS1" ]] ; then + if [[ -n "$DNS1" && -z "$setupDNS1" ]] ; then change_setting "PIHOLE_DNS_1" "${DNS1}" fi - if [[ -n "$DNS2" && -z "$setupDNS2" ]] ; then + if [[ -n "$DNS2" && -z "$setupDNS2" ]] ; then change_setting "PIHOLE_DNS_2" "${DNS2}" fi } @@ -78,7 +78,7 @@ setup_dnsmasq_interface() { interfaceType='custom' fi; echo "DNSMasq binding to $interfaceType interface: $INTERFACE" - [ -n "$INTERFACE" ] && change_setting "PIHOLE_INTERFACE" "${INTERFACE}" + [ -n "$INTERFACE" ] && change_setting "PIHOLE_INTERFACE" "${INTERFACE}" } setup_dnsmasq_config_if_missing() { @@ -174,11 +174,11 @@ setup_php_env_debian() { setup_php_env_alpine() { # Intentionally tabs, required by HEREDOC de-indentation (<<-) cat <<-EOF > "$PHP_ENV_CONFIG" - [www] - env[PATH] = ${PATH} - env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG} - env[ServerIP] = ${ServerIP} - EOF + [www] + env[PATH] = ${PATH} + env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG} + env[ServerIP] = ${ServerIP} + EOF if [ -z "$VIRTUAL_HOST" ] ; then VIRTUAL_HOST="$ServerIP" @@ -224,10 +224,10 @@ setup_web_password() { fi; set -x if [[ "$WEBPASSWORD" == "" ]] ; then - echo "" | pihole -a -p + echo "" | pihole -a -p else - pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" - fi + pihole -a -p "$WEBPASSWORD" "$WEBPASSWORD" + fi { set +x; } 2>/dev/null } @@ -274,10 +274,12 @@ test_configs_alpine() { test_framework_stubbing() { if [ -n "$PYTEST" ] ; then - echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block" - sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" - echo 'testblock.pi-hole.local' >> /etc/pihole/black.list - fi + echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block" + sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" + echo '123.123.123.123 testblock.pi-hole.local' > /var/www/html/fake.list + echo 'file:///var/www/html/fake.list' > /etc/pihole/adlists.txt + echo 'http://localhost/fake.list' >> /etc/pihole/adlists.txt + fi } docker_main() { diff --git a/install.sh b/install.sh index 7f8cac0..205db88 100755 --- a/install.sh +++ b/install.sh @@ -65,7 +65,11 @@ if [[ $USE_DEVELOPMENT_BRANCHES == true ]] ; then pushd "${PI_HOLE_LOCAL_REPO}"; git checkout development; popd; pushd "${webInterfaceDir}"; git checkout devel; popd; else - pushd "${PI_HOLE_LOCAL_REPO}"; git reset --hard "${CORE_TAG}"; popd; + pushd "${PI_HOLE_LOCAL_REPO}"; + git reset --hard "${CORE_TAG}"; + # Can be removed once https://github.com/pi-hole/pi-hole/pull/1779 is in a release + git checkout 8d721d086cbe4b49665c9e0b1d81499b284776a9 gravity.sh + popd; pushd "${webInterfaceDir}"; git reset --hard "${WEB_TAG}"; popd; fi diff --git a/test/test_start.py b/test/test_start.py index e54d875..19c3bac 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -65,7 +65,7 @@ def test_javascript_requests_load_as_expected(RunningPiHole, addr, url): http_rc = RunningPiHole.run(command) assert http_rc.rc == 0 assert int(http_rc.stdout) == 200 - assert RunningPiHole.run('md5sum /tmp/curled_file /var/www/html/pihole/index.js').rc == 0 + assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in RunningPiHole.run('cat /tmp/curled_file').stdout # IPv6 checks aren't passing CORS, removed :( @pytest.mark.parametrize('addr', [ 'localhost' ] ) From 7c6c48e1337fec5982e98f330b048c93a92caed1 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 7 Dec 2017 23:39:34 -0600 Subject: [PATCH 5/5] rest of loading tests fixed, undo heredoc tab2space --- bash_functions.sh | 14 +++++++------- test/test_start.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index f6e3f1e..4778113 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -174,11 +174,11 @@ setup_php_env_debian() { setup_php_env_alpine() { # Intentionally tabs, required by HEREDOC de-indentation (<<-) cat <<-EOF > "$PHP_ENV_CONFIG" - [www] - env[PATH] = ${PATH} - env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG} - env[ServerIP] = ${ServerIP} - EOF + [www] + env[PATH] = ${PATH} + env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG} + env[ServerIP] = ${ServerIP} + EOF if [ -z "$VIRTUAL_HOST" ] ; then VIRTUAL_HOST="$ServerIP" @@ -277,8 +277,8 @@ test_framework_stubbing() { echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block" sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" echo '123.123.123.123 testblock.pi-hole.local' > /var/www/html/fake.list - echo 'file:///var/www/html/fake.list' > /etc/pihole/adlists.txt - echo 'http://localhost/fake.list' >> /etc/pihole/adlists.txt + echo 'file:///var/www/html/fake.list' > /etc/pihole/adlists.list + echo 'http://localhost/fake.list' >> /etc/pihole/adlists.list fi } diff --git a/test/test_start.py b/test/test_start.py index 19c3bac..325b7d0 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -56,7 +56,7 @@ def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url): assert http_rc.rc == 0 assert int(http_rc.stdout) == 200 page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout - assert 'blocked' in page_contents + assert 'testblock.pi-hole.local' in page_contents @pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ]) @pytest.mark.parametrize('url', [ '/index.js', '/any.js'] )