From c341e0316f1ef59dad9315454d84375c0fd11c54 Mon Sep 17 00:00:00 2001 From: diginc Date: Sun, 28 Aug 2016 02:15:56 -0500 Subject: [PATCH] adding some missing files from merger mistakes --- .gitmodules | 2 +- .travis.yml | 14 ++++++-------- alpine.docker | 2 +- alpine/nginx.conf | 5 +++++ alpine/start.sh | 6 ++++-- autotest | 1 + debian.docker | 3 ++- debian/start.sh | 6 ++++-- test/__init__.py | 0 test/test_000_build_containers.py | 18 ++++++++++++++++++ 10 files changed, 42 insertions(+), 15 deletions(-) create mode 100755 autotest create mode 100644 test/__init__.py create mode 100644 test/test_000_build_containers.py diff --git a/.gitmodules b/.gitmodules index a808b3a..4ac310c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/pi-hole/pi-hole.git [submodule "AdminLTE"] path = AdminLTE - url = https://github.com/diginc/AdminLTE.git + url = https://github.com/pi-hole/AdminLTE.git diff --git a/.travis.yml b/.travis.yml index 46b023b..655f84e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,10 @@ sudo: required - services: - docker +language: python +python: + - "2.7" +install: + - pip install -r requirements.txt -before_install: - - docker pull diginc/pi-hole:alpine - - docker pull diginc/pi-hole:debian - -script: - - docker build -f alpine.docker . - - docker build -f debian.docker . +script: py.test -v diff --git a/alpine.docker b/alpine.docker index b39248c..065fab1 100644 --- a/alpine.docker +++ b/alpine.docker @@ -20,7 +20,7 @@ COPY ./pi-hole/advanced/Scripts/* /usr/local/bin/ RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/ -COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html +COPY ./pi-hole/advanced/index* /var/www/html/pihole/ COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole COPY ./AdminLTE /var/www/html/admin COPY ./AdminLTE_version.txt /etc/ diff --git a/alpine/nginx.conf b/alpine/nginx.conf index 0e3260a..b2e89aa 100644 --- a/alpine/nginx.conf +++ b/alpine/nginx.conf @@ -29,6 +29,11 @@ http { } } + location /*.js { + index pihole/index.js + error_page 404 =200 /pihole/index.js; + } + location / { add_header X-Pi-hole "A black hole for Internet advertisements." always; } diff --git a/alpine/start.sh b/alpine/start.sh index ea83d51..703d11a 100755 --- a/alpine/start.sh +++ b/alpine/start.sh @@ -13,7 +13,7 @@ echo "env[ServerIP] = ${ServerIP}" >> $PHP_ENV_CONFIG; if [ -n "$VIRTUAL_HOST" ] ; then echo "env[VIRTUAL_HOST] = ${VIRTUAL_HOST}" >> $PHP_ENV_CONFIG; -else +else echo "env[VIRTUAL_HOST] = ${ServerIP}" >> $PHP_ENV_CONFIG; fi; @@ -23,7 +23,7 @@ cat $PHP_ENV_CONFIG dnsType='default' DNS1=${DNS1:-'8.8.8.8'} DNS2=${DNS2:-'8.8.4.4'} -if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then +if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then dnsType='custom' fi; @@ -34,7 +34,9 @@ sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \ dnsmasq --test -7 /etc/dnsmasq.d || exit 1 php-fpm -t || exit 1 nginx -t || exit 1 +echo " :: All config checks passed, starting ..." +if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup/#donotcurl/g' `which gravity.sh`; fi; gravity.sh dnsmasq -7 /etc/dnsmasq.d php-fpm diff --git a/autotest b/autotest new file mode 100755 index 0000000..3747cc0 --- /dev/null +++ b/autotest @@ -0,0 +1 @@ +py.test -v -f test/ diff --git a/debian.docker b/debian.docker index 5fae7c2..71fd761 100644 --- a/debian.docker +++ b/debian.docker @@ -26,7 +26,8 @@ RUN mkdir -p /opt/ && ln -s /usr/local/bin /opt/pihole COPY ./pi-hole/advanced/lighttpd.conf.debian /etc/lighttpd/lighttpd.conf COPY ./pi-hole/advanced/dnsmasq.conf.original /etc/dnsmasq.conf COPY ./pi-hole/advanced/01-pihole.conf /etc/dnsmasq.d/ -COPY ./pi-hole/advanced/index.html /var/www/html/pihole/index.html +COPY ./pi-hole/advanced/index* /var/www/html/pihole/ +RUN rm /var/www/html/index.lighttpd.html COPY ./pi-hole/advanced/pihole.sudo /etc/sudoers.d/pihole COPY ./AdminLTE /var/www/html/admin COPY ./AdminLTE_version.txt /etc/ diff --git a/debian/start.sh b/debian/start.sh index 9e1d517..02797cb 100755 --- a/debian/start.sh +++ b/debian/start.sh @@ -11,7 +11,7 @@ sed -i "/bin-environment/ a\\\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\"," $ if [ -n "$VIRTUAL_HOST" ] ; then sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${VIRTUAL_HOST}\"," $PHP_ENV_CONFIG -else +else sed -i "/bin-environment/ a\\\t\t\t\"VIRTUAL_HOST\" => \"${ServerIP}\"," $PHP_ENV_CONFIG fi; @@ -21,7 +21,7 @@ grep -E '(VIRTUAL_HOST|ServerIP)' $PHP_ENV_CONFIG dnsType='default' DNS1=${DNS1:-'8.8.8.8'} DNS2=${DNS2:-'8.8.4.4'} -if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then +if [ "$DNS1" != '8.8.8.8' ] || [ "$DNS2" != '8.8.4.4' ] ; then dnsType='custom' fi; @@ -31,7 +31,9 @@ sed -i "s/@DNS2@/$DNS2/" /etc/dnsmasq.d/01-pihole.conf && \ dnsmasq --test -7 /etc/dnsmasq.d || exit 1 lighttpd -t -f /etc/lighttpd/lighttpd.conf || exit 1 +echo " :: All config checks passed, starting ..." +if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup/#donotcurl/g' `which gravity.sh`; fi; gravity.sh # dnsmasq start included service lighttpd start diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_000_build_containers.py b/test/test_000_build_containers.py new file mode 100644 index 0000000..ac9ae85 --- /dev/null +++ b/test/test_000_build_containers.py @@ -0,0 +1,18 @@ +''' This file starts with 000 to make it run first ''' +import pytest +import testinfra + +run_local = testinfra.get_backend( + "local://" +).get_module("Command").run + +@pytest.mark.parametrize("image,tag", [ + ( 'alpine.docker', 'diginc/pi-hole:alpine' ), + ( 'debian.docker', 'diginc/pi-hole:debian' ), +]) +def test_build_pihole_image(image, tag): + build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag)) + if build_cmd.rc != 0: + print build_cmd.stdout + print build_cmd.stderr + assert build_cmd.rc == 0