Fix ServerIP v4 validation - error can also be about DNS not being up yet

This commit is contained in:
diginc 2018-01-26 18:26:46 -06:00
parent 39a8802c74
commit 9b7e3998d6
5 changed files with 9 additions and 5 deletions

View File

@ -19,7 +19,7 @@ validate_env() {
nc_error='Name or service not known'
# Required ServerIP is a valid IP
if nc -w1 -z "$ServerIP" 53 2>&1 | grep -q "$nc_error" ; then
if [[ "$(nc -4 -w1 -z "$ServerIP" 53 2>&1)" != "" ]]; then
echo "ERROR: ServerIP Environment variable ($ServerIP) doesn't appear to be a valid IPv4 address"
exit 1
fi

View File

@ -60,7 +60,7 @@ sed -i $'s/helpFunc() {/unsupportedFunc() {\\\n echo "Function not supported in
# Replace references to `updatePiholeFunc` with new `unsupportedFunc`
sed -i $'s/updatePiholeFunc;;/unsupportedFunc;;/g' /usr/local/bin/pihole
mv "${tmpLog}" "${instalLogLoc}"
mv "${tmpLog}" /
touch /.piholeFirstBoot
# Fix dnsmasq in docker

View File

@ -7,8 +7,11 @@ if [ "${PH_VERBOSE:-0}" -gt 0 ] ; then
bashCmd='bash -e -x'
fi
$bashCmd /start.sh
# Start dnsmasq for validate_env and gravity.sh
dnsmasq -7 /etc/dnsmasq.d
$bashCmd /start.sh
gravity.sh
# Kill dnsmasq because s6 won't like it if it's running when s6 services start
kill -9 $(pgrep dnsmasq) || true

View File

@ -18,6 +18,7 @@ export WEB_PORT
. /bash_functions.sh
echo " ::: Starting docker specific setup for docker diginc/pi-hole"
set -e
validate_env || exit 1
prepare_setup_vars
change_setting "IPV4_ADDRESS" "$ServerIP"

View File

@ -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 += " -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)