2022-09-18 21:44:06 +02:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2024-07-27 21:55:18 +02:00
|
|
|
# Source utils.sh for getFTLConfigValue()
|
2022-09-18 21:44:06 +02:00
|
|
|
PI_HOLE_SCRIPT_DIR='/opt/pihole'
|
|
|
|
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
. "${utilsfile}"
|
|
|
|
|
|
|
|
# Get file paths
|
2024-07-27 21:55:18 +02:00
|
|
|
FTL_PID_FILE="$(getFTLConfigValue files.pid)"
|
2022-09-18 21:44:06 +02:00
|
|
|
|
|
|
|
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
2025-02-24 17:01:17 +01:00
|
|
|
mkdir -p /var/log/pihole
|
2023-08-05 14:54:09 +02:00
|
|
|
chown -R pihole:pihole /etc/pihole /var/log/pihole
|
2025-02-24 17:01:17 +01:00
|
|
|
find /etc/pihole /var/log/pihole -type d -exec chmod 0755 {} +
|
|
|
|
find /etc/pihole /var/log/pihole -type f ! \( -name '*.pem' -o -name '*.crt' \) -exec chmod 0640 {} +
|
|
|
|
find /etc/pihole /var/log/pihole -type f -name '*.pem' -o -name '*.crt' -exec chmod 0600 {} +
|
2023-10-13 19:59:29 +02:00
|
|
|
|
2025-02-24 17:01:17 +01:00
|
|
|
# Logrotate config file need to be owned by root
|
2023-10-18 22:09:38 +02:00
|
|
|
chown root:root /etc/pihole/logrotate
|
2023-10-13 19:59:29 +02:00
|
|
|
|
|
|
|
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
|
|
|
[ -f "${FTL_PID_FILE}" ] || install -D -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
|
|
|
|
[ -f /var/log/pihole/FTL.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/FTL.log
|
|
|
|
[ -f /var/log/pihole/pihole.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/pihole.log
|
|
|
|
[ -f /etc/pihole/dhcp.leases ] || install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases
|