Add webserver log to piholeLogFlush.sh

Signed-off-by: Jack'lul <8418678+jacklul@users.noreply.github.com>
This commit is contained in:
Jack'lul 2025-03-05 22:25:33 +01:00 committed by GitHub
parent 9fe687bd62
commit 4df5c0bb96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,6 +35,10 @@ FTLFILE=$(getFTLConfigValue "files.log.ftl")
if [ -z "$FTLFILE" ]; then if [ -z "$FTLFILE" ]; then
FTLFILE="/var/log/pihole/FTL.log" FTLFILE="/var/log/pihole/FTL.log"
fi fi
WEBFILE=$(getFTLConfigValue "files.log.webserver")
if [ -z "$WEBFILE" ]; then
WEBFILE="/var/log/pihole/webserver.log"
fi
if [[ "$*" == *"once"* ]]; then if [[ "$*" == *"once"* ]]; then
# Nightly logrotation # Nightly logrotation
@ -71,6 +75,17 @@ if [[ "$*" == *"once"* ]]; then
if [[ "$*" != *"quiet"* ]]; then if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Rotated ${FTLFILE} ..." echo -e "${OVER} ${TICK} Rotated ${FTLFILE} ..."
fi fi
# Copy webserver.log over to webserver.log.1
# and empty out webserver.log
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Rotating ${WEBFILE} ..."
fi
cp -p "${WEBFILE}" "${WEBFILE}.1"
echo " " > "${WEBFILE}"
chmod 640 "${WEBFILE}"
if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Rotated ${WEBFILE} ..."
fi
fi fi
else else
# Manual flushing # Manual flushing
@ -103,6 +118,20 @@ else
echo -e "${OVER} ${TICK} Flushed ${FTLFILE} ..." echo -e "${OVER} ${TICK} Flushed ${FTLFILE} ..."
fi fi
# Flush both webserver.log and webserver.log.1 (if existing)
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Flushing ${WEBFILE} ..."
fi
echo " " > "${WEBFILE}"
chmod 640 "${WEBFILE}"
if [ -f "${WEBFILE}.1" ]; then
echo " " > "${WEBFILE}.1"
chmod 640 "${WEBFILE}.1"
fi
if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Flushed ${WEBFILE} ..."
fi
if [[ "$*" != *"quiet"* ]]; then if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Flushing database, DNS resolution temporarily unavailable ..." echo -ne " ${INFO} Flushing database, DNS resolution temporarily unavailable ..."
fi fi