1
0
mirror of https://github.com/pi-hole/docker-pi-hole.git synced 2024-06-21 15:06:40 +02:00

Merge pull request #62 from diginc/dev

Dev Test additions
This commit is contained in:
Adam Hill 2016-10-22 13:59:15 -05:00 committed by GitHub
commit 2d5e69879a
8 changed files with 39 additions and 23 deletions

View File

@ -7,4 +7,4 @@ python:
install:
- pip install -r requirements.txt
script: py.test -v
script: py.test -vv

View File

@ -1 +1 @@
py.test -v -f test/
py.test -f ./test -v $@

View File

@ -41,30 +41,32 @@ setup_php_env_debian() {
local php_error_line="\t\t\t\"PHP_ERROR_LOG\" => \"${PHP_ERROR_LOG}\","
# idempotent line additions
grep -q "$vhost_line" $PHP_ENV_CONFIG || \
sed -i "/bin-environment/ a\\${vhost_line}" $PHP_ENV_CONFIG
grep -q "$serverip_line" $PHP_ENV_CONFIG || \
sed -i "/bin-environment/ a\\${serverip_line}" $PHP_ENV_CONFIG
grep -q "$php_error_line" $PHP_ENV_CONFIG || \
sed -i "/bin-environment/ a\\${php_error_line}" $PHP_ENV_CONFIG
grep -q "$vhost_line" "$PHP_ENV_CONFIG" || \
sed -i "/bin-environment/ a\\${vhost_line}" "$PHP_ENV_CONFIG"
grep -q "$serverip_line" "$PHP_ENV_CONFIG" || \
sed -i "/bin-environment/ a\\${serverip_line}" "$PHP_ENV_CONFIG"
grep -q "$php_error_line" "$PHP_ENV_CONFIG" || \
sed -i "/bin-environment/ a\\${php_error_line}" "$PHP_ENV_CONFIG"
echo "Added ENV to php:"
grep -E '(VIRTUAL_HOST|ServerIP|PHP_ERROR_LOG)' $PHP_ENV_CONFIG
grep -E '(VIRTUAL_HOST|ServerIP|PHP_ERROR_LOG)' "$PHP_ENV_CONFIG"
}
setup_php_env_alpine() {
echo "[www]" > $PHP_ENV_CONFIG;
echo "env[PATH] = ${PATH}" >> $PHP_ENV_CONFIG;
echo "env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG}" >> $PHP_ENV_CONFIG;
echo "env[ServerIP] = ${ServerIP}" >> $PHP_ENV_CONFIG;
cat <<-EOF > "$PHP_ENV_CONFIG"
[www]
env[PATH] = ${PATH}
env[PHP_ERROR_LOG] = ${PHP_ERROR_LOG}
env[ServerIP] = ${ServerIP}
EOF
if [ -z "$VIRTUAL_HOST" ] ; then
VIRTUAL_HOST="$ServerIP"
fi;
echo "env[VIRTUAL_HOST] = ${VIRTUAL_HOST}" >> $PHP_ENV_CONFIG;
echo "env[VIRTUAL_HOST] = ${VIRTUAL_HOST}" >> "$PHP_ENV_CONFIG";
echo "Added ENV to php:"
cat $PHP_ENV_CONFIG
cat "$PHP_ENV_CONFIG"
}
setup_ipv4_ipv6() {
@ -109,5 +111,5 @@ test_configs_alpine() {
}
test_framework_stubbing() {
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#donotcurl/g' `which gravity.sh`; fi;
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"; fi;
}

View File

@ -6,6 +6,7 @@ docker build -f debian.docker -t diginc/pi-hole:debian .
IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
# Alternative ports to not conflict with my real instance
# shellcheck disable=SC2068
docker run -it --rm --cap-add=NET_ADMIN \
-p 5053:53/tcp \
-p 5053:53/udp \
@ -13,5 +14,5 @@ docker run -it --rm --cap-add=NET_ADMIN \
-e ServerIP="$IP" \
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
$@ \
diginc/pi-hole:${image:-alpine}
diginc/pi-hole:"${image:-alpine}"

View File

@ -1,11 +1,11 @@
#!/bin/bash
IMAGE=${1:-'diginc/pi-hole:alpine'}
NIC=${2:-'eth0'}
IP=$(ip addr show $NIC | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
IP=$(ip addr show "$NIC" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
# Default ports + daemonized docker container
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \
--cap-add=NET_ADMIN \
-e ServerIP="$IP" \
--name pihole \
-d $IMAGE
-d "$IMAGE"

View File

@ -1,11 +1,11 @@
#!/bin/sh -e
supportedTags='^(alpine|debian)$'
if ! (echo $1 | grep -Pq "$supportedTags") ; then
if ! (echo "$1" | grep -Pq "$supportedTags") ; then
echo "$1 is not a supported tag"; exit 1;
fi
unlink docker-compose.yml
unlink Dockerfile
ln -s doco-${1}.yml docker-compose.yml
ln -s ${1}.docker Dockerfile
ln -s "doco-${1}.yml" docker-compose.yml
ln -s "${1}.docker" Dockerfile

13
test/test_shellcheck.py Normal file
View File

@ -0,0 +1,13 @@
import pytest
import testinfra
run_local = testinfra.get_backend(
"local://"
).get_module("Command").run
def test_scripts_pass_shellcheck():
''' Make sure shellcheck does not find anything wrong with our shell scripts '''
shellcheck = "find . ! -path './pi-hole/*' -name '*.sh' -a ! -name 'gravity.sh' | while read file; do shellcheck $file; done;"
results = run_local(shellcheck)
print results.stdout
assert '' == results.stdout

View File

@ -10,7 +10,7 @@ pushd AdminLTE ; git describe --tags --abbrev=0 > ../AdminLTE_version.txt ; popd
cron='./docker-pi-hole.cron'
cp -f pi-hole/advanced/pihole.cron ${cron};
sed -i '/Update the ad sources/ i\# Your container name goes here:\nDOCKER_NAME=pihole\nPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin\n' ${cron};
sed -i 's|/usr/local/bin/|docker exec $DOCKER_NAME |g' ${cron};
sed -i "s|/usr/local/bin/|docker exec \$DOCKER_NAME |g" ${cron};
sed -i '/docker exec/ s|$| > /dev/null|g' ${cron};
# docker-pi-hole users update their docker images, not git code