1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-12-22 23:08:07 +00:00

Update existing logrotate files to inlcude webserver.log

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König 2024-08-27 21:24:50 +02:00 committed by yubiuser
parent e3fc5cc8f2
commit a21b4c5203

View File

@ -1496,6 +1496,7 @@ create_pihole_user() {
installLogrotate() { installLogrotate() {
local str="Installing latest logrotate script" local str="Installing latest logrotate script"
local target=/etc/pihole/logrotate local target=/etc/pihole/logrotate
local logfileUpdate=false
printf "\\n %b %s..." "${INFO}" "${str}" printf "\\n %b %s..." "${INFO}" "${str}"
if [[ -f ${target} ]]; then if [[ -f ${target} ]]; then
@ -1506,17 +1507,35 @@ installLogrotate() {
sed -i 's/\/var\/log\/pihole-FTL.log/\/var\/log\/pihole\/FTL.log/g' ${target} sed -i 's/\/var\/log\/pihole-FTL.log/\/var\/log\/pihole\/FTL.log/g' ${target}
printf "\\n\\t%b Old log file paths updated in existing logrotate file. \\n" "${INFO}" printf "\\n\\t%b Old log file paths updated in existing logrotate file. \\n" "${INFO}"
return 3 logfileUpdate=true
fi fi
printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${INFO}" # Account for added webserver.log in v6.0
# Return value isn't that important, using 2 to indicate that it's not a fatal error but if ! grep -q "/var/log/pihole/webserver.log" ${target}; then
# the function did not complete. echo "/var/log/pihole/webserver.log {
return 2 # su #
weekly
copytruncate
rotate 3
compress
delaycompress
notifempty
nomail
}" >> ${target}
printf "\\n\\t%b webserver.log added to logrotate file. \\n" "${INFO}"
logfileUpdate=true
fi fi
if [[ "${logfileUpdate}" == false ]]; then
printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${INFO}"
return
fi
else
# Copy the file over from the local repo # Copy the file over from the local repo
# Logrotate config file must be owned by root and not writable by group or other # Logrotate config file must be owned by root and not writable by group or other
install -o root -g root -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${target} install -o root -g root -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${target}
fi
# Different operating systems have different user / group # Different operating systems have different user / group
# settings for logrotate that makes it impossible to create # settings for logrotate that makes it impossible to create
# a static logrotate file that will work with e.g. # a static logrotate file that will work with e.g.