From 2f384525652e3e617bfd5e13e9ed09b0165a9176 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 31 Mar 2022 12:03:17 -0700 Subject: [PATCH 1/6] Wrap touch calls with if/then guards for Buster docker. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 1e004b8b..99e4dc47 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1128,8 +1128,10 @@ chooseBlocklists() { appendToListsFile "${choice}" done # Create an empty adList file with appropriate permissions. - touch "${adlistFile}" - chmod 644 "${adlistFile}" + if [ ! -f "${adlistFile}" ]; then + touch "${adlistFile}" + chmod 644 "${adlistFile}" + fi } # Accept a string parameter, it must be one of the default lists @@ -1330,8 +1332,10 @@ installConfigs() { # and copy in the config file Pi-hole needs install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} "${lighttpdConfig}" # Make sure the external.conf file exists, as lighttpd v1.4.50 crashes without it - touch /etc/lighttpd/external.conf - chmod 644 /etc/lighttpd/external.conf + if [ ! -f /etc/lighttpd/external.conf ]; then + touch /etc/lighttpd/external.conf + chmod 644 /etc/lighttpd/external.conf + fi # If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config if [[ -f "${PI_HOLE_BLOCKPAGE_DIR}/custom.php" ]]; then sed -i 's/^\(server\.error-handler-404\s*=\s*\).*$/\1"\/pihole\/custom\.php"/' "${lighttpdConfig}" From c2384ecc6f5bc55e4d00c37e56666e891c0d8f46 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 31 Mar 2022 14:23:39 -0700 Subject: [PATCH 2/6] Change touch that would always fire to install. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 99e4dc47..4c173d05 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1333,8 +1333,7 @@ installConfigs() { install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} "${lighttpdConfig}" # Make sure the external.conf file exists, as lighttpd v1.4.50 crashes without it if [ ! -f /etc/lighttpd/external.conf ]; then - touch /etc/lighttpd/external.conf - chmod 644 /etc/lighttpd/external.conf + install -m 644 /dev/null /etc/lighttpd/external.com fi # If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config if [[ -f "${PI_HOLE_BLOCKPAGE_DIR}/custom.php" ]]; then From d45c9fc52293d907d6871cc7f3cf701c9d88c376 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 1 Apr 2022 11:08:26 -0700 Subject: [PATCH 3/6] Final touch to install fix. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 4c173d05..f2720d5d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1129,7 +1129,7 @@ chooseBlocklists() { done # Create an empty adList file with appropriate permissions. if [ ! -f "${adlistFile}" ]; then - touch "${adlistFile}" + install /dev/null "${adlistFile}" chmod 644 "${adlistFile}" fi } From 8a5c7dec719bb29f4717b0e679afc585d915c45e Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 31 Mar 2022 14:32:07 -0700 Subject: [PATCH 4/6] Ensure existing files are proper owner and mode. Signed-off-by: Dan Schaper co-authored-by: RD WebDesign --- advanced/Templates/pihole-FTL.service | 11 +++++++---- automated install/basic-install.sh | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index 865e2cd9..23f4f125 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -21,12 +21,15 @@ start() { else # Touch files to ensure they exist (create if non-existing, preserve if existing) mkdir -pm 0755 /run/pihole - touch /run/pihole-FTL.pid /run/pihole-FTL.port /var/log/pihole-FTL.log /var/log/pihole.log /etc/pihole/dhcp.leases + [ ! -f /run/pihole-FTL.pid ] && install -m 644 -o pihole -g pihole dev/null /run/pihole-FTL.pid + [ ! -f /run/pihole-FTL.port ] && install -m 644 -o pihole -g pihole dev/null /run/pihole-FTL.port + [ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole dev/null /var/log/pihole.log + [ ! -f /var/log/pihole.log ] && install -m 644 -o pihole -g pihole dev/null /var/log/pihole.log + [ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole 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 /etc/pihole /var/log/pihole.log /var/log/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 + chmod -f 0644 /etc/pihole/macvendor.db /etc/pihole/dhcp.leases /var/log/pihole-FTL.log /var/log/pihole.log # Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db # 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 diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f2720d5d..62366f8a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1129,7 +1129,8 @@ chooseBlocklists() { done # Create an empty adList file with appropriate permissions. if [ ! -f "${adlistFile}" ]; then - install /dev/null "${adlistFile}" + install -m 644 /dev/null "${adlistFile}" + else chmod 644 "${adlistFile}" fi } @@ -1333,7 +1334,7 @@ installConfigs() { install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/advanced/${LIGHTTPD_CFG} "${lighttpdConfig}" # Make sure the external.conf file exists, as lighttpd v1.4.50 crashes without it if [ ! -f /etc/lighttpd/external.conf ]; then - install -m 644 /dev/null /etc/lighttpd/external.com + install -m 644 /dev/null /etc/lighttpd/external.conf fi # If there is a custom block page in the html/pihole directory, replace 404 handler in lighttpd config if [[ -f "${PI_HOLE_BLOCKPAGE_DIR}/custom.php" ]]; then From 0f192998eb52c46e20cd422513d8ae5a9a0edf8f Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 1 Apr 2022 14:17:57 -0700 Subject: [PATCH 5/6] Create empty files. Signed-off-by: Dan Schaper --- advanced/Templates/pihole-FTL.service | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index 23f4f125..d4a057ef 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -21,11 +21,11 @@ start() { else # Touch files to ensure they exist (create if non-existing, preserve if existing) mkdir -pm 0755 /run/pihole - [ ! -f /run/pihole-FTL.pid ] && install -m 644 -o pihole -g pihole dev/null /run/pihole-FTL.pid - [ ! -f /run/pihole-FTL.port ] && install -m 644 -o pihole -g pihole dev/null /run/pihole-FTL.port - [ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole dev/null /var/log/pihole.log - [ ! -f /var/log/pihole.log ] && install -m 644 -o pihole -g pihole dev/null /var/log/pihole.log - [ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole dev/null /etc/pihole/dhcp.leases + [ ! -f /run/pihole-FTL.pid ] && install -m 644 -o pihole -g pihole /dev/null /run/pihole-FTL.pid + [ ! -f /run/pihole-FTL.port ] && install -m 644 -o pihole -g pihole /dev/null /run/pihole-FTL.port + [ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole.log + [ ! -f /var/log/pihole.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole.log + [ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole /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 /etc/pihole /var/log/pihole.log /var/log/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 From b714c4598a615ae384e8f884936071d8b04e84f6 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 1 Apr 2022 14:49:30 -0700 Subject: [PATCH 6/6] Found it. Signed-off-by: Dan Schaper --- advanced/Templates/pihole-FTL.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Templates/pihole-FTL.service b/advanced/Templates/pihole-FTL.service index d4a057ef..41ab8018 100644 --- a/advanced/Templates/pihole-FTL.service +++ b/advanced/Templates/pihole-FTL.service @@ -23,7 +23,7 @@ start() { mkdir -pm 0755 /run/pihole [ ! -f /run/pihole-FTL.pid ] && install -m 644 -o pihole -g pihole /dev/null /run/pihole-FTL.pid [ ! -f /run/pihole-FTL.port ] && install -m 644 -o pihole -g pihole /dev/null /run/pihole-FTL.port - [ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole.log + [ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole-FTL.log [ ! -f /var/log/pihole.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole.log [ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases # Ensure that permissions are set so that pihole-FTL can edit all necessary files