From b7016668b4d840806df4e90d1b277f6081ac5079 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 12 Jun 2022 12:59:18 +0100 Subject: [PATCH 1/6] Account for log files being moved to /var/log/pihole/ Signed-off-by: Adam Warner --- s6/debian-root/etc/services.d/pihole-FTL/run | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 00a75a0..bc688a0 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -9,13 +9,13 @@ rm /run/pihole/FTL.sock 2> /dev/null mkdir -pm 0755 /run/pihole [[ ! -f /run/pihole-FTL.pid ]] && install /dev/null /run/pihole-FTL.pid [[ ! -f /run/pihole-FTL.port ]] && install /dev/null /run/pihole-FTL.port -[[ ! -f /var/log/pihole-FTL.log ]] && install /dev/null /var/log/pihole-FTL.log -[[ ! -f /var/log/pihole.log ]] && install /dev/null /var/log/pihole.log +[[ ! -f /var/log/pihole/pihole-FTL.log ]] && install /dev/null /var/log/pihole/pihole-FTL.log +[[ ! -f /var/log/pihole/pihole.log ]] && install /dev/null /var/log/pihole/pihole.log [[ ! -f /etc/pihole/dhcp.leases ]] && install /dev/null /etc/pihole/dhcp.leases # Ensure that permissions are set so that pihole-FTL can edit all necessary files -chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole -chmod 0644 /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases +chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole +chmod 0644 /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases # Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist chmod -f 0644 /etc/pihole/macvendor.db @@ -24,6 +24,18 @@ chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pih # Chown database file permissions so that the pihole group (web interface) can edit the file. We ignore errors as the files may not (yet) exist chmod -f 0664 /etc/pihole/pihole-FTL.db +# Backward compatibility for user-scripts that still expect log files in /var/log instead of /var/log/pihole/ +# Should be removed with Pi-hole v6.0 +if [ ! -f /var/log/pihole.log ]; then + ln -s /var/log/pihole/pihole.log /var/log/pihole.log + chown -h pihole:pihole /var/log/pihole.log + +fi +if [ ! -f /var/log/pihole-FTL.log ]; then + ln -s /var/log/pihole/pihole-FTL.log /var/log/pihole-FTL.log + chown -h pihole:pihole /var/log/pihole-FTL.log +fi + # Call capsh with the detected capabilities capsh --inh=${CAP_STR:1} --addamb=${CAP_STR:1} --user=$DNSMASQ_USER --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null 2>&1" From 1900d567c941803ef23247105b0e761c86df6db6 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 12 Jun 2022 13:10:12 +0100 Subject: [PATCH 2/6] Mop up some other references Signed-off-by: Adam Warner --- docker-compose-nginx-proxy.yml | 2 +- s6/debian-root/etc/cont-init.d/20-start.sh | 2 +- s6/debian-root/etc/services.d/pihole-FTL/run | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose-nginx-proxy.yml b/docker-compose-nginx-proxy.yml index fe74aea..48b34f9 100644 --- a/docker-compose-nginx-proxy.yml +++ b/docker-compose-nginx-proxy.yml @@ -24,7 +24,7 @@ services: - './etc-pihole:/etc/pihole' - './etc-dnsmasq.d:/etc/dnsmasq.d' # run `touch ./var-log/pihole.log` first unless you like errors - # - './var-log/pihole.log:/var/log/pihole.log' + # - './var-log/pihole.log:/var/log/pihole/pihole.log' # Recommended but not required (DHCP needs NET_ADMIN) # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: diff --git a/s6/debian-root/etc/cont-init.d/20-start.sh b/s6/debian-root/etc/cont-init.d/20-start.sh index 97cd6ab..78efae6 100644 --- a/s6/debian-root/etc/cont-init.d/20-start.sh +++ b/s6/debian-root/etc/cont-init.d/20-start.sh @@ -28,7 +28,7 @@ if [ -z "$SKIPGRAVITYONBOOT" ] || [ ! -e "${gravityDBfile}" ]; then echo " Ignoring SKIPGRAVITYONBOOT on this occaision." fi - echo '@reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log' > /etc/cron.d/gravity-on-boot + echo '@reboot root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log' > /etc/cron.d/gravity-on-boot else echo " Skipping Gravity Database Update." [ ! -e /etc/cron.d/gravity-on-boot ] || rm /etc/cron.d/gravity-on-boot &>/dev/null diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index bc688a0..11b6f98 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -41,5 +41,5 @@ capsh --inh=${CAP_STR:1} --addamb=${CAP_STR:1} --user=$DNSMASQ_USER --keep=1 -- # Notes on above: # - DNSMASQ_USER default of pihole is in Dockerfile & can be overwritten by runtime container env -# - /var/log/pihole*.log has FTL's output that no-daemon would normally print in FG too +# - /var/log/pihole/pihole*.log has FTL's output that no-daemon would normally print in FG too # prevent duplicating it in docker logs by sending to dev null From f17898bf6f402268a626e7e24c7dab14635cfdde Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 12 Jun 2022 13:37:39 +0100 Subject: [PATCH 3/6] Also account for /var/log/lighttpd file name changes Signed-off-by: Adam Warner --- Dockerfile | 2 +- .../etc/services.d/lighttpd-access-log/run | 2 +- s6/debian-root/etc/services.d/lighttpd-error-log/run | 2 +- s6/debian-root/etc/services.d/lighttpd/run | 12 ++++++------ test/test_bash_functions.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5cd5d9c..067f969 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN bash -ex install.sh 2>&1 && \ 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.log +ENV PHP_ERROR_LOG /var/log/lighttpd/error-pihole.log COPY ./start.sh / COPY ./bash_functions.sh / diff --git a/s6/debian-root/etc/services.d/lighttpd-access-log/run b/s6/debian-root/etc/services.d/lighttpd-access-log/run index 1473767..61d7cbb 100644 --- a/s6/debian-root/etc/services.d/lighttpd-access-log/run +++ b/s6/debian-root/etc/services.d/lighttpd-access-log/run @@ -2,4 +2,4 @@ s6-echo "Starting lighttpd-access-log" -s6-setuidgid www-data cat /var/log/lighttpd/access.log 2>&1 +s6-setuidgid www-data cat /var/log/lighttpd/access-pihole.log 2>&1 diff --git a/s6/debian-root/etc/services.d/lighttpd-error-log/run b/s6/debian-root/etc/services.d/lighttpd-error-log/run index c0636fc..45e666a 100644 --- a/s6/debian-root/etc/services.d/lighttpd-error-log/run +++ b/s6/debian-root/etc/services.d/lighttpd-error-log/run @@ -2,4 +2,4 @@ s6-echo "Starting lighttpd-error-log" -s6-setuidgid www-data cat /var/log/lighttpd/error.log 2>&1 +s6-setuidgid www-data cat /var/log/lighttpd/error-pihole.log 2>&1 diff --git a/s6/debian-root/etc/services.d/lighttpd/run b/s6/debian-root/etc/services.d/lighttpd/run index 2cd314a..98140b4 100644 --- a/s6/debian-root/etc/services.d/lighttpd/run +++ b/s6/debian-root/etc/services.d/lighttpd/run @@ -4,7 +4,7 @@ s6-echo "Starting lighttpd" if [[ 1 -eq ${WEBLOGS_STDOUT:-0} ]]; then #lighthttpd cannot use /dev/stdout https://redmine.lighttpd.net/issues/2731 - for fi in /var/log/lighttpd/access.log /var/log/lighttpd/error.log + for fi in /var/log/lighttpd/access-pihole.log /var/log/lighttpd/erro-pihole.log do if [[ ! -p ${fi} ]]; then rm -f ${fi} @@ -17,16 +17,16 @@ if [[ 1 -eq ${WEBLOGS_STDOUT:-0} ]]; then sleep 2 else #remove fifo if exists - [[ -p /var/log/lighttpd/access.log ]] && rm -Rf /var/log/lighttpd/access.log - [[ -p /var/log/lighttpd/error.log ]] && rm -Rf /var/log/lighttpd/error.log + [[ -p /var/log/lighttpd/access-pihole.log ]] && rm -Rf /var/log/lighttpd/access-pihole.log + [[ -p /var/log/lighttpd/error-pihole.log ]] && rm -Rf /var/log/lighttpd/error-pihole.log # install /dev/null log files to ensure they exist (create if non-existing, preserve if existing) - [[ ! -f /var/log/lighttpd/access.log ]] && install /dev/null /var/log/lighttpd/access.log - [[ ! -f /var/log/lighttpd/error.log ]] && install /dev/null /var/log/lighttpd/error.log + [[ ! -f /var/log/lighttpd/access-pihole.log ]] && install /dev/null /var/log/lighttpd/access-pihole.log + [[ ! -f /var/log/lighttpd/error-pihole.log ]] && install /dev/null /var/log/lighttpd/error-pihole.log # Ensure that permissions are set so that lighttpd can write to the logs chown -R www-data:www-data /var/log/lighttpd - chmod 0644 /var/log/lighttpd/access.log /var/log/lighttpd/error.log + chmod 0644 /var/log/lighttpd/access-pihole.log /var/log/lighttpd/error-pihole.log fi lighttpd -D -f /etc/lighttpd/lighttpd.conf diff --git a/test/test_bash_functions.py b/test/test_bash_functions.py index 6898072..ebdfce1 100644 --- a/test/test_bash_functions.py +++ b/test/test_bash_functions.py @@ -162,7 +162,7 @@ def test_dns_interface_override_defaults(docker, slow, args_env, expected_stdout expected_debian_lines = [ '"VIRTUAL_HOST" => "127.0.0.1"', '"ServerIP" => "127.0.0.1"', - '"PHP_ERROR_LOG" => "/var/log/lighttpd/error.log"' + '"PHP_ERROR_LOG" => "/var/log/lighttpd/error-pihole.log"' ] From 05bf32abdacc9eaf48de271f8d88cd0dc761e364 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sun, 12 Jun 2022 17:56:47 +0100 Subject: [PATCH 4/6] Update s6/debian-root/etc/services.d/lighttpd/run Co-authored-by: yubiuser Signed-off-by: Adam Warner --- s6/debian-root/etc/services.d/lighttpd/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s6/debian-root/etc/services.d/lighttpd/run b/s6/debian-root/etc/services.d/lighttpd/run index 98140b4..8a314fb 100644 --- a/s6/debian-root/etc/services.d/lighttpd/run +++ b/s6/debian-root/etc/services.d/lighttpd/run @@ -4,7 +4,7 @@ s6-echo "Starting lighttpd" if [[ 1 -eq ${WEBLOGS_STDOUT:-0} ]]; then #lighthttpd cannot use /dev/stdout https://redmine.lighttpd.net/issues/2731 - for fi in /var/log/lighttpd/access-pihole.log /var/log/lighttpd/erro-pihole.log + for fi in /var/log/lighttpd/access-pihole.log /var/log/lighttpd/error-pihole.log do if [[ ! -p ${fi} ]]; then rm -f ${fi} From 855086caa783c851da71216636295868788ac36f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Mon, 4 Jul 2022 15:40:53 +0100 Subject: [PATCH 5/6] Update s6/debian-root/etc/services.d/pihole-FTL/run Signed-off-by: Adam Warner --- s6/debian-root/etc/services.d/pihole-FTL/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 11b6f98..831145d 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -9,7 +9,7 @@ rm /run/pihole/FTL.sock 2> /dev/null mkdir -pm 0755 /run/pihole [[ ! -f /run/pihole-FTL.pid ]] && install /dev/null /run/pihole-FTL.pid [[ ! -f /run/pihole-FTL.port ]] && install /dev/null /run/pihole-FTL.port -[[ ! -f /var/log/pihole/pihole-FTL.log ]] && install /dev/null /var/log/pihole/pihole-FTL.log +[[ ! -f /var/log/pihole/FTL.log ]] && install /dev/null /var/log/pihole/FTL.log [[ ! -f /var/log/pihole/pihole.log ]] && install /dev/null /var/log/pihole/pihole.log [[ ! -f /etc/pihole/dhcp.leases ]] && install /dev/null /etc/pihole/dhcp.leases From 33bae3207f84a962c79818027b5e3d45a2d631f8 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 8 Jul 2022 17:25:29 +0100 Subject: [PATCH 6/6] Also account for renaming of pihole-FTL.log -> FTL.log Signed-off-by: Adam Warner --- s6/debian-root/etc/services.d/pihole-FTL/run | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 831145d..ababe8d 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -6,7 +6,7 @@ rm -f /dev/shm/FTL-* 2> /dev/null rm /run/pihole/FTL.sock 2> /dev/null # install /dev/null files to ensure they exist (create if non-existing, preserve if existing) -mkdir -pm 0755 /run/pihole +mkdir -pm 0755 /run/pihole /var/log/pihole [[ ! -f /run/pihole-FTL.pid ]] && install /dev/null /run/pihole-FTL.pid [[ ! -f /run/pihole-FTL.port ]] && install /dev/null /run/pihole-FTL.port [[ ! -f /var/log/pihole/FTL.log ]] && install /dev/null /var/log/pihole/FTL.log @@ -14,8 +14,8 @@ mkdir -pm 0755 /run/pihole [[ ! -f /etc/pihole/dhcp.leases ]] && install /dev/null /etc/pihole/dhcp.leases # Ensure that permissions are set so that pihole-FTL can edit all necessary files -chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole -chmod 0644 /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases +chown pihole:pihole /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases /run/pihole /etc/pihole +chmod 0644 /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole/FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases # Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist chmod -f 0644 /etc/pihole/macvendor.db @@ -32,7 +32,7 @@ if [ ! -f /var/log/pihole.log ]; then fi if [ ! -f /var/log/pihole-FTL.log ]; then - ln -s /var/log/pihole/pihole-FTL.log /var/log/pihole-FTL.log + ln -s /var/log/pihole/FTL.log /var/log/pihole-FTL.log chown -h pihole:pihole /var/log/pihole-FTL.log fi