From 3cb043eb10d311fb5bc24c390f7097fb4b6f041c Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Thu, 31 Mar 2022 15:00:47 -0300 Subject: [PATCH] Use `touch` only if we need to create an absent file Signed-off-by: RD WebDesign --- s6/debian-root/etc/services.d/lighttpd/run | 4 +++- s6/debian-root/etc/services.d/pihole-FTL/run | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/s6/debian-root/etc/services.d/lighttpd/run b/s6/debian-root/etc/services.d/lighttpd/run index b60786b..8d03ad3 100644 --- a/s6/debian-root/etc/services.d/lighttpd/run +++ b/s6/debian-root/etc/services.d/lighttpd/run @@ -19,8 +19,10 @@ 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 + # Touch log files to ensure they exist (create if non-existing, preserve if existing) - touch /var/log/lighttpd/access.log /var/log/lighttpd/error.log + [[ ! -f /var/log/lighttpd/access.log ]] && touch /var/log/lighttpd/access.log + [[ ! -f /var/log/lighttpd/error.log ]] && touch /var/log/lighttpd/error.log # Ensure that permissions are set so that lighttpd can write to the logs chown -R www-data:www-data /var/log/lighttpd diff --git a/s6/debian-root/etc/services.d/pihole-FTL/run b/s6/debian-root/etc/services.d/pihole-FTL/run index 046daad..1b983af 100644 --- a/s6/debian-root/etc/services.d/pihole-FTL/run +++ b/s6/debian-root/etc/services.d/pihole-FTL/run @@ -7,7 +7,11 @@ rm /run/pihole/FTL.sock 2> /dev/null # 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 ]] && touch /run/pihole-FTL.pid +[[ ! -f /run/pihole-FTL.port ]] && touch /run/pihole-FTL.port +[[ ! -f /var/log/pihole-FTL.log ]] && touch /var/log/pihole-FTL.log +[[ ! -f /var/log/pihole.log ]] && touch /var/log/pihole.log +[[ ! -f /etc/pihole/dhcp.leases ]] && touch /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