mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-24 12:28:56 +00:00
re-do a few things to fix up test/handle updated code
This commit is contained in:
@@ -58,5 +58,6 @@ ENV IPv6 True
|
|||||||
EXPOSE 53 53/udp
|
EXPOSE 53 53/udp
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
ENTRYPOINT ["/tini", "--"]
|
ENTRYPOINT ["/tini", "--"]
|
||||||
CMD [ "/start.sh" ]
|
CMD [ "/start.sh" ]
|
||||||
|
|||||||
@@ -27,9 +27,10 @@ http {
|
|||||||
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
add_header X-Pi-hole "The Pi-hole Web interface is working!";
|
||||||
location ~ .php$ {
|
location ~ .php$ {
|
||||||
fastcgi_pass 127.0.0.1:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
setupVars="${setupVars:-/etc/pihole/setupVars.conf}"
|
. /opt/pihole/webpage.sh
|
||||||
|
|
||||||
validate_env() {
|
validate_env() {
|
||||||
if [ -z "$ServerIP" ] ; then
|
if [ -z "$ServerIP" ] ; then
|
||||||
@@ -7,14 +7,8 @@ validate_env() {
|
|||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_saved_variables() {
|
|
||||||
# /tmp/piholeIP is the current override of auto-lookup in gravity.sh
|
|
||||||
echo "$ServerIP" > /etc/pihole/piholeIP;
|
|
||||||
echo "IPV4_ADDRESS=$ServerIP" > "${setupVars}";
|
|
||||||
echo "IPV6_ADDRESS=$ServerIPv6" >> "${setupVars}";
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_dnsmasq_dns() {
|
setup_dnsmasq_dns() {
|
||||||
|
. /opt/pihole/webpage.sh
|
||||||
local DNS1="${1:-8.8.8.8}"
|
local DNS1="${1:-8.8.8.8}"
|
||||||
local DNS2="${2:-8.8.4.4}"
|
local DNS2="${2:-8.8.4.4}"
|
||||||
local dnsType='default'
|
local dnsType='default'
|
||||||
@@ -22,10 +16,10 @@ setup_dnsmasq_dns() {
|
|||||||
dnsType='custom'
|
dnsType='custom'
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
set -x
|
|
||||||
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
|
echo "Using $dnsType DNS servers: $DNS1 & $DNS2"
|
||||||
sed -i 's/ProcessDnsmasqSettings/ProcessDNSSettings/g' /opt/pihole/webpage.sh
|
[ -n "$DNS1" ] && change_setting "PIHOLE_DNS_1" "${DNS1}"
|
||||||
sudo pihole -a setdns "$DNS1" "$DNS2"
|
[ -n "$DNS2" ] && change_setting "PIHOLE_DNS_2" "${DNS2}"
|
||||||
|
ProcessDNSSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_dnsmasq_hostnames() {
|
setup_dnsmasq_hostnames() {
|
||||||
@@ -155,9 +149,9 @@ test_framework_stubbing() {
|
|||||||
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"; fi;
|
if [ -n "$PYTEST" ] ; then sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)"; fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
docker_main() {
|
||||||
echo -n '::: Starting up DNS and Webserver ...'
|
echo -n '::: Starting up DNS and Webserver ...'
|
||||||
pihole restartdns # Just get DNS up. The webserver is down!!!
|
service dnsmasq restart # Just get DNS up. The webserver is down!!!
|
||||||
|
|
||||||
IMAGE="$1"
|
IMAGE="$1"
|
||||||
case $IMAGE in # Setup webserver
|
case $IMAGE in # Setup webserver
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ ENV IPv6 True
|
|||||||
EXPOSE 53 53/udp
|
EXPOSE 53 53/udp
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
ENTRYPOINT ["/tini", "--"]
|
ENTRYPOINT ["/tini", "--"]
|
||||||
CMD [ "/start.sh" ]
|
CMD [ "/start.sh" ]
|
||||||
|
|
||||||
|
|||||||
@@ -33,5 +33,6 @@ ENV IPv6 True
|
|||||||
EXPOSE 53 53/udp
|
EXPOSE 53 53/udp
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-c"]
|
||||||
ENTRYPOINT ["/tini", "--"]
|
ENTRYPOINT ["/tini", "--"]
|
||||||
CMD [ "/start.sh" ]
|
CMD [ "/start.sh" ]
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ export IPV6_ADDRESS=0:0:0:0:0:0
|
|||||||
export PIHOLE_DNS_1=8.8.8.8
|
export PIHOLE_DNS_1=8.8.8.8
|
||||||
export PIHOLE_DNS_2=8.8.4.4
|
export PIHOLE_DNS_2=8.8.4.4
|
||||||
export QUERY_LOGGING=true
|
export QUERY_LOGGING=true
|
||||||
|
|
||||||
installPihole | tee "${tmpLog}"
|
installPihole | tee "${tmpLog}"
|
||||||
|
sed -i 's/readonly //g' /opt/pihole/webpage.sh
|
||||||
|
|
||||||
mv "${tmpLog}" "${instalLogLoc}"
|
mv "${tmpLog}" "${instalLogLoc}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
docker-compose
|
docker-compose
|
||||||
pytest==2.9.2
|
pytest
|
||||||
pytest-cov==2.3.0
|
pytest-cov
|
||||||
pytest-xdist==1.14
|
pytest-xdist
|
||||||
testinfra==1.5.1
|
testinfra==1.5.1
|
||||||
|
|||||||
15
start.sh
15
start.sh
@@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -ex
|
||||||
. /bash_functions.sh
|
|
||||||
# Dockerfile variables
|
# Dockerfile variables
|
||||||
export IMAGE
|
export IMAGE
|
||||||
export ServerIP
|
export ServerIP
|
||||||
@@ -9,16 +8,22 @@ export PHP_ENV_CONFIG
|
|||||||
export PHP_ERROR_LOG
|
export PHP_ERROR_LOG
|
||||||
export HOSTNAME
|
export HOSTNAME
|
||||||
export WEBLOGDIR
|
export WEBLOGDIR
|
||||||
|
export DNS1
|
||||||
|
export DNS2
|
||||||
export IPv6
|
export IPv6
|
||||||
|
#export setupVars="${setupVars:-/etc/pihole/setupVars.conf}"
|
||||||
|
|
||||||
|
. /bash_functions.sh
|
||||||
|
|
||||||
|
echo " ::: Starting docker specific setup for docker diginc/pi-hole"
|
||||||
validate_env
|
validate_env
|
||||||
setup_saved_variables
|
change_setting "IPV4_ADDRESS" "$ServerIP"
|
||||||
setup_php_env
|
change_setting "IPV6_ADDRESS" "$ServerIPv6"
|
||||||
setup_dnsmasq_dns "$DNS1" "$DNS2"
|
setup_dnsmasq_dns "$DNS1" "$DNS2"
|
||||||
|
setup_php_env
|
||||||
setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME"
|
setup_dnsmasq_hostnames "$ServerIP" "$ServerIPv6" "$HOSTNAME"
|
||||||
setup_ipv4_ipv6
|
setup_ipv4_ipv6
|
||||||
test_configs
|
test_configs
|
||||||
test_framework_stubbing
|
test_framework_stubbing
|
||||||
|
|
||||||
main "$IMAGE"
|
docker_main "$IMAGE"
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ def cmd(request):
|
|||||||
])
|
])
|
||||||
def test_IPv6_not_True_removes_ipv6(Docker, tag, args, expected_ipv6, expected_stdout):
|
def test_IPv6_not_True_removes_ipv6(Docker, tag, args, expected_ipv6, expected_stdout):
|
||||||
''' When a user overrides IPv6=True they only get IPv4 listening webservers '''
|
''' When a user overrides IPv6=True they only get IPv4 listening webservers '''
|
||||||
IPV6_LINE = { 'alpine': 'listen \[::\]:80', 'debian': 'use-ipv6.pl' }
|
IPV6_LINE = { 'alpine': 'listen \[::\]:80',
|
||||||
WEB_CONFIG = { 'alpine': '/etc/nginx/nginx.conf', 'debian': '/etc/lighttpd/lighttpd.conf' }
|
'debian': 'use-ipv6.pl' }
|
||||||
|
WEB_CONFIG = { 'alpine': '/etc/nginx/nginx.conf',
|
||||||
|
'debian': '/etc/lighttpd/lighttpd.conf' }
|
||||||
|
|
||||||
function = Docker.run('. /bash_functions.sh ; setup_ipv4_ipv6')
|
function = Docker.run('. /bash_functions.sh ; setup_ipv4_ipv6')
|
||||||
assert "Using {}".format(expected_stdout) in function.stdout
|
assert "Using {}".format(expected_stdout) in function.stdout
|
||||||
@@ -38,7 +39,7 @@ def test_DNS_Envs_override_defaults(Docker, args, expected_stdout, dns1, dns2):
|
|||||||
expected_servers = 'server={}\nserver={}\n'.format(dns1, dns2)
|
expected_servers = 'server={}\nserver={}\n'.format(dns1, dns2)
|
||||||
assert expected_servers == docker_dns_servers
|
assert expected_servers == docker_dns_servers
|
||||||
|
|
||||||
expected_debian_lines = [
|
expected_debian_lines = [
|
||||||
'"VIRTUAL_HOST" => "192.168.100.2"',
|
'"VIRTUAL_HOST" => "192.168.100.2"',
|
||||||
'"ServerIP" => "192.168.100.2"',
|
'"ServerIP" => "192.168.100.2"',
|
||||||
'"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"'
|
'"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"'
|
||||||
|
|||||||
Reference in New Issue
Block a user