diff --git a/src/Dockerfile b/src/Dockerfile index 670a0d0..d4693db 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -6,7 +6,6 @@ ENV PIHOLE_DOCKER_TAG "${PIHOLE_DOCKER_TAG}" ENV S6_OVERLAY_VERSION v3.1.1.2 -COPY ./scripts/install.sh /usr/local/bin/install.sh ENV PIHOLE_INSTALL /etc/.pihole/automated\ install/basic-install.sh ENTRYPOINT [ "/s6-init" ] @@ -22,9 +21,6 @@ ARG PHP_ENV_CONFIG ENV PHP_ENV_CONFIG /etc/lighttpd/conf-enabled/15-fastcgi-php.conf ARG PHP_ERROR_LOG ENV PHP_ERROR_LOG /var/log/lighttpd/error-pihole.log -COPY ./scripts/start.sh / -COPY ./scripts/bash_functions.sh / -COPY ./scripts/gravityonboot.sh / # IPv6 disable flag for networks/devices that do not support it ENV IPv6 True diff --git a/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_gravityonboot/up b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_gravityonboot/up index c292158..af0c454 100755 --- a/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_gravityonboot/up +++ b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_gravityonboot/up @@ -1,2 +1,2 @@ #!/command/execlineb -background { bash -e /gravityonboot.sh } \ No newline at end of file +background { bash -e /usr/local/bin/gravityonboot.sh } \ No newline at end of file diff --git a/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/dependencies b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/dependencies new file mode 100644 index 0000000..fd10531 --- /dev/null +++ b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/dependencies @@ -0,0 +1 @@ +_uid-gid-changer \ No newline at end of file diff --git a/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/up b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/up index e5d3fb1..cf8427d 100755 --- a/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/up +++ b/src/s6/debian-root/etc/s6-overlay/s6-rc.d/_startup/up @@ -1,2 +1,2 @@ #!/command/execlineb -foreground { bash -e /start.sh } \ No newline at end of file +foreground { bash -e /usr/local/bin/start.sh } \ No newline at end of file diff --git a/src/scripts/bash_functions.sh b/src/s6/debian-root/usr/local/bin/bash_functions.sh similarity index 100% rename from src/scripts/bash_functions.sh rename to src/s6/debian-root/usr/local/bin/bash_functions.sh diff --git a/src/scripts/gravityonboot.sh b/src/s6/debian-root/usr/local/bin/gravityonboot.sh similarity index 100% rename from src/scripts/gravityonboot.sh rename to src/s6/debian-root/usr/local/bin/gravityonboot.sh diff --git a/src/scripts/install.sh b/src/s6/debian-root/usr/local/bin/install.sh similarity index 100% rename from src/scripts/install.sh rename to src/s6/debian-root/usr/local/bin/install.sh diff --git a/src/scripts/start.sh b/src/s6/debian-root/usr/local/bin/start.sh similarity index 98% rename from src/scripts/start.sh rename to src/s6/debian-root/usr/local/bin/start.sh index 79b4034..071cd34 100755 --- a/src/scripts/start.sh +++ b/src/s6/debian-root/usr/local/bin/start.sh @@ -6,7 +6,7 @@ fi # The below functions are all contained in bash_functions.sh # shellcheck source=/dev/null -. /bash_functions.sh +. /usr/local/bin/bash_functions.sh # shellcheck source=/dev/null SKIP_INSTALL=true . "${PIHOLE_INSTALL}" diff --git a/test/tests/test_bash_functions.py b/test/tests/test_bash_functions.py index 73eb0f5..41f8106 100644 --- a/test/tests/test_bash_functions.py +++ b/test/tests/test_bash_functions.py @@ -43,7 +43,7 @@ def test_overrides_default_web_port(docker, slow, test_args): CONFIG_LINE = r'server.port\s*=\s*999' WEB_CONFIG = '/etc/lighttpd/lighttpd.conf' - function = docker.run('. /bash_functions.sh ; eval `grep setup_web_port /start.sh`') + function = docker.run('. /bash_functions.sh ; eval `grep setup_web_port /usr/local/bin/start.sh`') assert "Custom WEB_PORT set to 999" in function.stdout assert "INFO: Without proper router DNAT forwarding to 127.0.0.1:999, you may not get any blocked websites on ads" in function.stdout slow(lambda: re.search(CONFIG_LINE, docker.run(_cat(WEB_CONFIG)).stdout) != None) @@ -55,7 +55,7 @@ def test_overrides_default_web_port(docker, slow, test_args): ('-e WEB_PORT="99999"', 'WARNING: Custom WEB_PORT not used - 99999 is not within valid port range of 1-65535'), ]) def test_bad_input_to_web_port(docker, test_args, expected_error): - function = docker.run('. /bash_functions.sh ; eval `grep setup_web_port /start.sh`') + function = docker.run('. /bash_functions.sh ; eval `grep setup_web_port /usr/local/bin/start.sh`') assert expected_error in function.stdout @@ -64,7 +64,7 @@ def test_overrides_default_custom_cache_size(docker, slow, test_args, cache_size ''' Changes the cache_size setting to increase or decrease the cache size for dnsmasq''' CONFIG_LINE = r'cache-size\s*=\s*{}'.format(cache_size) - function = docker.run('echo ${CUSTOM_CACHE_SIZE};. ./bash_functions.sh; echo ${CUSTOM_CACHE_SIZE}; eval `grep setup_FTL_CacheSize /start.sh`') + function = docker.run('echo ${CUSTOM_CACHE_SIZE};. ./bash_functions.sh; echo ${CUSTOM_CACHE_SIZE}; eval `grep setup_FTL_CacheSize /usr/local/bin/start.sh`') assert "Custom CUSTOM_CACHE_SIZE set to {}".format(cache_size) in function.stdout slow(lambda: re.search(CONFIG_LINE, docker.run(_cat(DNSMASQ_CONFIG_LOC)).stdout) != None) @@ -113,7 +113,7 @@ expected_debian_lines = [ def test_debian_setup_php_env(docker, expected_lines, repeat_function): ''' confirm all expected output is there and nothing else ''' for _ in range(repeat_function): - docker.run('. /bash_functions.sh ; eval `grep setup_php_env /start.sh`').stdout + docker.run('. /bash_functions.sh ; eval `grep setup_php_env /usr/local/bin/start.sh`').stdout for expected_line in expected_lines: search_config_cmd = "grep -c '{}' /etc/lighttpd/conf-enabled/15-fastcgi-php.conf".format(expected_line) search_config_count = docker.run(search_config_cmd) diff --git a/test/tests/test_start.py b/test/tests/test_start.py index 9ee3259..da079e2 100644 --- a/test/tests/test_start.py +++ b/test/tests/test_start.py @@ -5,7 +5,7 @@ import time docker containers (esp. musl based OSs) stripped down nature ''' -# If the test runs /start.sh, do not let s6 run it too! Kill entrypoint to avoid race condition/duplicated execution +# If the test runs /usr/local/bin/start.sh, do not let s6 run it too! Kill entrypoint to avoid race condition/duplicated execution @pytest.mark.parametrize('entrypoint,cmd', [('--entrypoint=tail','-f /dev/null')]) @pytest.mark.parametrize('args,error_msg,expect_rc', [ ('-e FTLCONF_LOCAL_IPV4="1.2.3.z"', "FTLCONF_LOCAL_IPV4 Environment variable (1.2.3.z) doesn't appear to be a valid IPv4 address",1), @@ -13,7 +13,7 @@ import time ('-e FTLCONF_LOCAL_IPV4="1.2.3.4" -e FTLCONF_LOCAL_IPV6="kernel"', "ERROR: You passed in IPv6 with a value of 'kernel'",1), ]) def test_ftlconf_local_addr_invalid_ips_triggers_exit_error(docker, error_msg, expect_rc): - start = docker.run('/start.sh') + start = docker.run('/usr/local/bin/start.sh') assert start.rc == expect_rc assert 'ERROR' in start.stdout assert error_msg in start.stdout