mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-24 13:50:17 +00:00
b166410cbf
Simplified the command -v syntax, and added a sleep 3 timer to the first execution of the log rotation. The second execution was being issued while the first was still running, thus it would fail and you would have to issue the "Flush Logs" command a second time.
24 lines
836 B
Bash
Executable file
24 lines
836 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Pi-hole: A black hole for Internet advertisements
|
|
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
|
# Network-wide ad blocking via your own hardware.
|
|
#
|
|
# Flushes Pi-hole's log file
|
|
#
|
|
# This file is copyright under the latest version of the EUPL.
|
|
# Please see LICENSE file for your rights under this license.
|
|
|
|
echo -n "::: Flushing /var/log/pihole.log ..."
|
|
# Test if logrotate is available on this system
|
|
if command -v /usr/sbin/logrotate >/dev/null; then
|
|
# Flush 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
|
|
else
|
|
# Flush both pihole.log and pihole.log.1 (if existing)
|
|
echo " " > /var/log/pihole.log
|
|
if [ -f /var/log/pihole.log.1 ]; then
|
|
echo " " > /var/log/pihole.log.1
|
|
fi
|
|
fi
|
|
echo "... done!"
|