From 5c17e41cf147f7cba3dc24dbaba2db03813980a1 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 3 Apr 2020 19:05:59 +0200 Subject: [PATCH] Start pihole-FTL after network "$network" on a systemd-driven OS leads to "After=network-online.target" in the generated systemd unit. This target is no guarantee that all network interfaces have been fully configured, as it depends on the related network services types, but at least it reduces the risk that those have not fully finished their job when pihole-FTL starts. If this is the case, certain issues can occur: - https://github.com/pi-hole/pi-hole/issues/2924 - https://discourse.pi-hole.net/t/have-to-pihole-restartdns-after-reboot/28772 Runtime files are now consistently created in "/run" instead of "/var/run". The second is a symlink to the first for backwards compatibility but on none-ancient distro versions one should use "/run", systemd even prints a warnings if service files use "/var/run". The service file used "/run" and "/var/run" both, in cases for the same files/directories before, which does not directly cause issues currently, due to the symlink, but is inconsistent at best. Signed-off-by: MichaIng --- advanced/Scripts/chronometer.sh | 2 +- advanced/Templates/pihole-FTL.service | 12 ++++++------ advanced/lighttpd.conf.debian | 2 +- advanced/lighttpd.conf.fedora | 2 +- automated install/basic-install.sh | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 757df9be..7431c212 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -13,7 +13,7 @@ LC_NUMERIC=C # Retrieve stats from FTL engine pihole-FTL() { - ftl_port=$(cat /var/run/pihole-FTL.port 2> /dev/null) + ftl_port=$(cat /run/pihole-FTL.port 2> /dev/null) if [[ -n "$ftl_port" ]]; then # Open connection to FTL exec 3<>"/dev/tcp/127.0.0.1/$ftl_port" diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index f32a5e89..ab7f8f2b 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -1,8 +1,8 @@ #!/usr/bin/env bash ### BEGIN INIT INFO # Provides: pihole-FTL -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog +# Required-Start: $remote_fs $syslog $network +# Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: pihole-FTL daemon @@ -10,7 +10,7 @@ ### END INIT INFO FTLUSER=pihole -PIDFILE=/var/run/pihole-FTL.pid +PIDFILE=/run/pihole-FTL.pid get_pid() { # First, try to obtain PID from PIDFILE @@ -37,12 +37,12 @@ start() { touch /var/log/pihole-FTL.log /var/log/pihole.log touch /run/pihole-FTL.pid /run/pihole-FTL.port touch /etc/pihole/dhcp.leases - mkdir -p /var/run/pihole + mkdir -p /run/pihole mkdir -p /var/log/pihole - chown pihole:pihole /var/run/pihole /var/log/pihole + chown pihole:pihole /run/pihole /var/log/pihole # Remove possible leftovers from previous pihole-FTL processes rm -f /dev/shm/FTL-* 2> /dev/null - rm /var/run/pihole/FTL.sock 2> /dev/null + rm /run/pihole/FTL.sock 2> /dev/null # 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 chown pihole:pihole /etc/pihole /etc/pihole/dhcp.leases 2> /dev/null diff --git a/advanced/lighttpd.conf.debian b/advanced/lighttpd.conf.debian index f96c2d4b..dab5c03e 100644 --- a/advanced/lighttpd.conf.debian +++ b/advanced/lighttpd.conf.debian @@ -30,7 +30,7 @@ server.document-root = "/var/www/html" server.error-handler-404 = "/pihole/index.php" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" -server.pid-file = "/var/run/lighttpd.pid" +server.pid-file = "/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 diff --git a/advanced/lighttpd.conf.fedora b/advanced/lighttpd.conf.fedora index 22299248..ea340e3f 100644 --- a/advanced/lighttpd.conf.fedora +++ b/advanced/lighttpd.conf.fedora @@ -31,7 +31,7 @@ server.document-root = "/var/www/html" server.error-handler-404 = "/pihole/index.php" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" -server.pid-file = "/var/run/lighttpd.pid" +server.pid-file = "/run/lighttpd.pid" server.username = "lighttpd" server.groupname = "lighttpd" server.port = 80 diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ac643037..ec4556e8 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1433,8 +1433,8 @@ installConfigs() { sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"pihole\/custom\.php"/' /etc/lighttpd/lighttpd.conf fi # Make the directories if they do not exist and set the owners - mkdir -p /var/run/lighttpd - chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/run/lighttpd + mkdir -p /run/lighttpd + chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /run/lighttpd mkdir -p /var/cache/lighttpd/compress chown ${LIGHTTPD_USER}:${LIGHTTPD_GROUP} /var/cache/lighttpd/compress mkdir -p /var/cache/lighttpd/uploads