Special renaming for pihole-FTL.* to pihole/FTL.log.*

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2022-07-03 18:54:13 +02:00
parent 98c238064e
commit bd8288d6ef
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
1 changed files with 13 additions and 1 deletions

View File

@ -2610,12 +2610,24 @@ main() {
# If this is an update from a previous Pi-hole installation
# we need to move any existing `pihole*` logs from `/var/log` to `/var/log/pihole`
# if /var/log/pihole.log is not a symlink (set durign FTL startup) move the files
# if /var/log/pihole.log is not a symlink (set during FTL startup) move the files
# can be removed with Pi-hole v6.0
# To be sure FTL is not running when we move the files we explicitly stop it here
stop_service pihole-FTL &> /dev/null
# Special handling for pihole-FTL.log -> pihole/FTL.log
if [ -f /var/log/pihole-FTL.log ] && [ ! -L /var/log/pihole-FTL.log ]; then
# /var/log/pihole-FTL.log -> /var/log/pihole/FTL.log
# /var/log/pihole-FTL.log.1 -> /var/log/pihole/FTL.log.1
# /var/log/pihole-FTL.log.2.gz -> /var/log/pihole/FTL.log.2.gz
# /var/log/pihole-FTL.log.3.gz -> /var/log/pihole/FTL.log.3.gz
# /var/log/pihole-FTL.log.4.gz -> /var/log/pihole/FTL.log.4.gz
# /var/log/pihole-FTL.log.5.gz -> /var/log/pihole/FTL.log.5.gz
for f in /var/log/pihole-FTL.log*; do mv "$f" "$( sed "s/pihole-/pihole\//" <<< "$f")"; done
fi
# Remaining log files
if [ -f /var/log/pihole.log ] && [ ! -L /var/log/pihole.log ]; then
mv /var/log/pihole*.* /var/log/pihole/ 2>/dev/null
fi