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/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/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..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.log /var/log/lighttpd/error.log + for fi in /var/log/lighttpd/access-pihole.log /var/log/lighttpd/error-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/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 00a75a0..ababe8d 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -6,16 +6,16 @@ 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 -[[ ! -f /var/log/pihole.log ]] && install /dev/null /var/log/pihole.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 # 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/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 @@ -24,10 +24,22 @@ 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/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" # 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 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"' ]