From a21b4c5203f1ff0fba37a34b2716c86c71152d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 27 Aug 2024 21:24:50 +0200 Subject: [PATCH] Update existing logrotate files to inlcude webserver.log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- automated install/basic-install.sh | 35 +++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9927b374..6b65313e 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1496,6 +1496,7 @@ create_pihole_user() { installLogrotate() { local str="Installing latest logrotate script" local target=/etc/pihole/logrotate + local logfileUpdate=false printf "\\n %b %s..." "${INFO}" "${str}" if [[ -f ${target} ]]; then @@ -1506,17 +1507,35 @@ installLogrotate() { 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}" - return 3 + logfileUpdate=true fi - printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${INFO}" - # Return value isn't that important, using 2 to indicate that it's not a fatal error but - # the function did not complete. - return 2 + # Account for added webserver.log in v6.0 + if ! grep -q "/var/log/pihole/webserver.log" ${target}; then + echo "/var/log/pihole/webserver.log { +# 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 + 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 + # 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} fi - # Copy the file over from the local repo - # 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} + # Different operating systems have different user / group # settings for logrotate that makes it impossible to create # a static logrotate file that will work with e.g.