1
0
mirror of https://github.com/pi-hole/docker-pi-hole.git synced 2024-06-21 15:06:40 +02:00

Use touch only if we need to create an absent file

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign 2022-03-31 15:00:47 -03:00
parent 41c1596915
commit 3cb043eb10
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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