mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Fix logrotation: manual flushing should be done twice, but automated rotation at midnight should only be done *once*!
This commit is contained in:
parent
ed04be5faa
commit
4e2c6a7b8e
3 changed files with 28 additions and 12 deletions
|
@ -9,9 +9,24 @@
|
||||||
# Please see LICENSE file for your rights under this license.
|
# Please see LICENSE file for your rights under this license.
|
||||||
|
|
||||||
echo -n "::: Flushing /var/log/pihole.log ..."
|
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||||
# Test if logrotate is available on this system
|
if [[ "$@" == *"once"* ]]; then
|
||||||
|
# Nightly logrotation
|
||||||
if command -v /usr/sbin/logrotate >/dev/null; then
|
if command -v /usr/sbin/logrotate >/dev/null; then
|
||||||
# Flush twice to move all data out of sight of FTL
|
# Logrotate once
|
||||||
|
/usr/sbin/logrotate --force /etc/pihole/logrotate
|
||||||
|
else
|
||||||
|
# Copy pihole.log over to pihole.log.1
|
||||||
|
# and empty out pihole.log
|
||||||
|
# Note that moving the file is not an option, as
|
||||||
|
# dnsmasq would happily continue writing into the
|
||||||
|
# moved file (it will have the same file handler)
|
||||||
|
cp /var/log/pihole.log /var/log/pihole.log.1
|
||||||
|
echo " " > /var/log/pihole.log
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Manual flushing
|
||||||
|
if command -v /usr/sbin/logrotate >/dev/null; then
|
||||||
|
# Logrotate twice to move all data out of sight of FTL
|
||||||
/usr/sbin/logrotate --force /etc/pihole/logrotate; sleep 3
|
/usr/sbin/logrotate --force /etc/pihole/logrotate; sleep 3
|
||||||
/usr/sbin/logrotate --force /etc/pihole/logrotate
|
/usr/sbin/logrotate --force /etc/pihole/logrotate
|
||||||
else
|
else
|
||||||
|
@ -21,4 +36,5 @@ else
|
||||||
echo " " > /var/log/pihole.log.1
|
echo " " > /var/log/pihole.log.1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
echo "... done!"
|
echo "... done!"
|
||||||
|
|
|
@ -24,6 +24,6 @@
|
||||||
# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
|
# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
|
||||||
# Stats will be viewable in the Web interface thanks to the cron job above
|
# Stats will be viewable in the Web interface thanks to the cron job above
|
||||||
# The flush script will use logrotate if available
|
# The flush script will use logrotate if available
|
||||||
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush
|
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush once
|
||||||
|
|
||||||
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate
|
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate
|
||||||
|
|
4
pihole
4
pihole
|
@ -61,7 +61,7 @@ debugFunc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
flushFunc() {
|
flushFunc() {
|
||||||
"${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh
|
"${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh "$@"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ case "${1}" in
|
||||||
"-b" | "blacklist" ) blacklistFunc "$@";;
|
"-b" | "blacklist" ) blacklistFunc "$@";;
|
||||||
"-wild" | "wildcard" ) wildcardFunc "$@";;
|
"-wild" | "wildcard" ) wildcardFunc "$@";;
|
||||||
"-d" | "debug" ) debugFunc "$@";;
|
"-d" | "debug" ) debugFunc "$@";;
|
||||||
"-f" | "flush" ) flushFunc;;
|
"-f" | "flush" ) flushFunc "$@";;
|
||||||
"-up" | "updatePihole" ) updatePiholeFunc;;
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||||
|
|
Loading…
Reference in a new issue