mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
If old log paths exist in logrotate file, replace them with new ones
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This commit is contained in:
parent
e0baf4c7ec
commit
ecfb96d339
1 changed files with 22 additions and 4 deletions
|
@ -1955,10 +1955,28 @@ installLogrotate() {
|
||||||
|
|
||||||
printf "\\n %b %s..." "${INFO}" "${str}"
|
printf "\\n %b %s..." "${INFO}" "${str}"
|
||||||
if [[ -f ${target} ]]; then
|
if [[ -f ${target} ]]; then
|
||||||
printf "\\n\\t%b Existing logrotate file found. No changes made.\\n" "${INFO}"
|
local touched=0
|
||||||
# Return value isn't that important, using 2 to indicate that it's not a fatal error but
|
|
||||||
# the function did not complete.
|
if grep -q "/var/log/pihole.log" ${target}; then
|
||||||
return 2
|
sed -i 's/\/var\/log\/pihole.log/\/var\/log\/pihole\/pihole.log/g' ${target}
|
||||||
|
touched=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if grep -q "/var/log/pihole-FTL.log" ${target}; then
|
||||||
|
sed -i 's/\/var\/log\/pihole-FTL.log/\/var\/log\/pihole\/FTL.log/g' ${target}
|
||||||
|
touched=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${touched}" -eq "0" ]; then
|
||||||
|
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
|
||||||
|
else
|
||||||
|
printf "\\n\\t%b Old log file paths updated in existing logrotate file. \\n" "${INFO}"
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
# Copy the file over from the local repo
|
# Copy the file over from the local repo
|
||||||
install -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${target}
|
install -D -m 644 -T "${PI_HOLE_LOCAL_REPO}"/advanced/Templates/logrotate ${target}
|
||||||
|
|
Loading…
Reference in a new issue