Skip to content

Commit

Permalink
Merge pull request #62 from diginc/dev
Browse files Browse the repository at this point in the history
Dev Test additions
  • Loading branch information
diginc authored Oct 22, 2016
2 parents 746f0be + 6c72116 commit 2d5e698
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ python:
install:
- pip install -r requirements.txt

script: py.test -v
script: py.test -vv
2 changes: 1 addition & 1 deletion autotest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
py.test -v -f test/
py.test -f ./test -v $@
30 changes: 16 additions & 14 deletions common_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion docker_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ 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 \
-p 5080:80 \
-e ServerIP="$IP" \
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
$@ \
diginc/pi-hole:${image:-alpine}
diginc/pi-hole:"${image:-alpine}"

4 changes: 2 additions & 2 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 3 additions & 3 deletions make_symlinks.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions test/test_shellcheck.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d5e698

Please sign in to comment.