mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 02:42:58 +00:00
Merge pull request #3732 from pi-hole/tweak/moveloglocation
Utilise /var/log/pihole/ for log storage
This commit is contained in:
commit
ae9d16baf2
11 changed files with 54 additions and 44 deletions
|
@ -37,6 +37,6 @@ interface=@INT@
|
||||||
cache-size=@CACHE_SIZE@
|
cache-size=@CACHE_SIZE@
|
||||||
|
|
||||||
log-queries
|
log-queries
|
||||||
log-facility=/var/log/pihole.log
|
log-facility=/var/log/pihole/pihole.log
|
||||||
|
|
||||||
log-async
|
log-async
|
||||||
|
|
|
@ -66,8 +66,8 @@ PIHOLE_DIRECTORY="/etc/pihole"
|
||||||
PIHOLE_SCRIPTS_DIRECTORY="/opt/pihole"
|
PIHOLE_SCRIPTS_DIRECTORY="/opt/pihole"
|
||||||
BIN_DIRECTORY="/usr/local/bin"
|
BIN_DIRECTORY="/usr/local/bin"
|
||||||
RUN_DIRECTORY="/run"
|
RUN_DIRECTORY="/run"
|
||||||
LOG_DIRECTORY="/var/log"
|
LOG_DIRECTORY="/var/log/pihole"
|
||||||
WEB_SERVER_LOG_DIRECTORY="${LOG_DIRECTORY}/lighttpd"
|
WEB_SERVER_LOG_DIRECTORY="/var/log/lighttpd"
|
||||||
WEB_SERVER_CONFIG_DIRECTORY="/etc/lighttpd"
|
WEB_SERVER_CONFIG_DIRECTORY="/etc/lighttpd"
|
||||||
HTML_DIRECTORY="/var/www/html"
|
HTML_DIRECTORY="/var/www/html"
|
||||||
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
|
WEB_GIT_DIRECTORY="${HTML_DIRECTORY}/admin"
|
||||||
|
|
|
@ -31,7 +31,7 @@ if [ -z "$DBFILE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$@" != *"quiet"* ]]; then
|
if [[ "$@" != *"quiet"* ]]; then
|
||||||
echo -ne " ${INFO} Flushing /var/log/pihole.log ..."
|
echo -ne " ${INFO} Flushing /var/log/pihole/pihole.log ..."
|
||||||
fi
|
fi
|
||||||
if [[ "$@" == *"once"* ]]; then
|
if [[ "$@" == *"once"* ]]; then
|
||||||
# Nightly logrotation
|
# Nightly logrotation
|
||||||
|
@ -44,9 +44,9 @@ if [[ "$@" == *"once"* ]]; then
|
||||||
# Note that moving the file is not an option, as
|
# Note that moving the file is not an option, as
|
||||||
# dnsmasq would happily continue writing into the
|
# dnsmasq would happily continue writing into the
|
||||||
# moved file (it will have the same file handler)
|
# moved file (it will have the same file handler)
|
||||||
cp -p /var/log/pihole.log /var/log/pihole.log.1
|
cp -p /var/log/pihole/pihole.log /var/log/pihole/pihole.log.1
|
||||||
echo " " > /var/log/pihole.log
|
echo " " > /var/log/pihole/pihole.log
|
||||||
chmod 644 /var/log/pihole.log
|
chmod 644 /var/log/pihole/pihole.log
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Manual flushing
|
# Manual flushing
|
||||||
|
@ -56,10 +56,10 @@ else
|
||||||
/usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
|
/usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
|
||||||
else
|
else
|
||||||
# Flush both pihole.log and pihole.log.1 (if existing)
|
# Flush both pihole.log and pihole.log.1 (if existing)
|
||||||
echo " " > /var/log/pihole.log
|
echo " " > /var/log/pihole/pihole.log
|
||||||
if [ -f /var/log/pihole.log.1 ]; then
|
if [ -f /var/log/pihole/pihole.log.1 ]; then
|
||||||
echo " " > /var/log/pihole.log.1
|
echo " " > /var/log/pihole/pihole.log.1
|
||||||
chmod 644 /var/log/pihole.log.1
|
chmod 644 /var/log/pihole/pihole.log.1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
|
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
|
||||||
|
@ -70,6 +70,6 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$@" != *"quiet"* ]]; then
|
if [[ "$@" != *"quiet"* ]]; then
|
||||||
echo -e "${OVER} ${TICK} Flushed /var/log/pihole.log"
|
echo -e "${OVER} ${TICK} Flushed /var/log/pihole/pihole.log"
|
||||||
echo -e " ${TICK} Deleted ${deleted} queries from database"
|
echo -e " ${TICK} Deleted ${deleted} queries from database"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/var/log/pihole.log {
|
/var/log/pihole/pihole.log {
|
||||||
# su #
|
# su #
|
||||||
daily
|
daily
|
||||||
copytruncate
|
copytruncate
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
nomail
|
nomail
|
||||||
}
|
}
|
||||||
|
|
||||||
/var/log/pihole-FTL.log {
|
/var/log/pihole/pihole-FTL.log {
|
||||||
# su #
|
# su #
|
||||||
weekly
|
weekly
|
||||||
copytruncate
|
copytruncate
|
||||||
|
|
|
@ -67,20 +67,33 @@ start() {
|
||||||
echo "pihole-FTL is already running"
|
echo "pihole-FTL is already running"
|
||||||
else
|
else
|
||||||
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
# Touch files to ensure they exist (create if non-existing, preserve if existing)
|
||||||
mkdir -pm 0755 /run/pihole
|
mkdir -pm 0755 /run/pihole /var/log/pihole
|
||||||
[ ! -f "${FTL_PID_FILE}" ] && install -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
|
[ ! -f "${FTL_PID_FILE}" ] && install -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
|
||||||
[ ! -f "${FTL_PORT_FILE}" ] && install -m 644 -o pihole -g pihole /dev/null "${FTL_PORT_FILE}"
|
[ ! -f "${FTL_PORT_FILE}" ] && install -m 644 -o pihole -g pihole /dev/null "${FTL_PORT_FILE}"
|
||||||
[ ! -f /var/log/pihole-FTL.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole-FTL.log
|
[ ! -f /var/log/pihole/pihole-FTL.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole/pihole-FTL.log
|
||||||
[ ! -f /var/log/pihole.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole.log
|
[ ! -f /var/log/pihole/pihole.log ] && install -m 644 -o pihole -g pihole /dev/null /var/log/pihole/pihole.log
|
||||||
[ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases
|
[ ! -f /etc/pihole/dhcp.leases ] && install -m 644 -o pihole -g pihole /dev/null /etc/pihole/dhcp.leases
|
||||||
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
# Ensure that permissions are set so that pihole-FTL can edit all necessary files
|
||||||
chown pihole:pihole /run/pihole /etc/pihole /var/log/pihole.log /var/log/pihole.log /etc/pihole/dhcp.leases
|
chown pihole:pihole /run/pihole /etc/pihole /var/log/pihole /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log /etc/pihole/dhcp.leases
|
||||||
# Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist
|
# Ensure that permissions are set so that pihole-FTL can edit the files. We ignore errors as the file may not (yet) exist
|
||||||
chmod -f 0644 /etc/pihole/macvendor.db /etc/pihole/dhcp.leases /var/log/pihole-FTL.log /var/log/pihole.log
|
chmod -f 0644 /etc/pihole/macvendor.db /etc/pihole/dhcp.leases /var/log/pihole/pihole-FTL.log /var/log/pihole/pihole.log
|
||||||
# Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist
|
# Chown database files to the user FTL runs as. We ignore errors as the files may not (yet) exist
|
||||||
chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db
|
chown -f pihole:pihole /etc/pihole/pihole-FTL.db /etc/pihole/gravity.db /etc/pihole/macvendor.db
|
||||||
# Chown database file permissions so that the pihole group (web interface) can edit the file. We ignore errors as the files may not (yet) exist
|
# Chown database file permissions so that the pihole group (web interface) can edit the file. We ignore errors as the files may not (yet) exist
|
||||||
chmod -f 0664 /etc/pihole/pihole-FTL.db
|
chmod -f 0664 /etc/pihole/pihole-FTL.db
|
||||||
|
|
||||||
|
# Backward compatibility for user-scripts that still expect log files in /var/log instead of /var/log/pihole/
|
||||||
|
# Should be removed with Pi-hole v6.0
|
||||||
|
if [ ! -f /var/log/pihole.log ]; then
|
||||||
|
ln -s /var/log/pihole/pihole.log /var/log/pihole.log
|
||||||
|
chown -h pihole:pihole /var/log/pihole.log
|
||||||
|
|
||||||
|
fi
|
||||||
|
if [ ! -f /var/log/pihole-FTL.log ]; then
|
||||||
|
ln -s /var/log/pihole/pihole-FTL.log /var/log/pihole-FTL.log
|
||||||
|
chown -h pihole:pihole /var/log/pihole-FTL.log
|
||||||
|
fi
|
||||||
|
|
||||||
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN+eip "/usr/bin/pihole-FTL"; then
|
if setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_IPC_LOCK,CAP_CHOWN+eip "/usr/bin/pihole-FTL"; then
|
||||||
su -s /bin/sh -c "/usr/bin/pihole-FTL" pihole
|
su -s /bin/sh -c "/usr/bin/pihole-FTL" pihole
|
||||||
else
|
else
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
# early morning. Download any updates from the adlists
|
# early morning. Download any updates from the adlists
|
||||||
# Squash output to log, then splat the log to stdout on error to allow for
|
# Squash output to log, then splat the log to stdout on error to allow for
|
||||||
# standard crontab job error handling.
|
# standard crontab job error handling.
|
||||||
59 1 * * 7 root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole_updateGravity.log || cat /var/log/pihole_updateGravity.log
|
59 1 * * 7 root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole updateGravity >/var/log/pihole/pihole_updateGravity.log || cat /var/log/pihole/pihole_updateGravity.log
|
||||||
|
|
||||||
# Pi-hole: Flush the log daily at 00:00
|
# Pi-hole: Flush the log daily at 00:00
|
||||||
# The flush script will use logrotate if available
|
# The flush script will use logrotate if available
|
||||||
|
|
|
@ -2613,6 +2613,19 @@ main() {
|
||||||
# Fixes a problem reported on Ubuntu 18.04 where trying to start
|
# Fixes a problem reported on Ubuntu 18.04 where trying to start
|
||||||
# the service before enabling causes installer to exit
|
# the service before enabling causes installer to exit
|
||||||
enable_service pihole-FTL
|
enable_service pihole-FTL
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# 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
|
||||||
|
|
||||||
|
if [ -f /var/log/pihole.log ] && [ ! -L /var/log/pihole.log ]; then
|
||||||
|
mv /var/log/pihole*.* /var/log/pihole/ 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
restart_service pihole-FTL
|
restart_service pihole-FTL
|
||||||
|
|
||||||
# Download and compile the aggregated block list
|
# Download and compile the aggregated block list
|
||||||
|
|
|
@ -146,6 +146,7 @@ removeNoPurge() {
|
||||||
${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${SUDO} rm -f /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
${SUDO} rm -f /etc/dnsmasq.d/06-rfc6761.conf &> /dev/null
|
${SUDO} rm -f /etc/dnsmasq.d/06-rfc6761.conf &> /dev/null
|
||||||
${SUDO} rm -rf /var/log/*pihole* &> /dev/null
|
${SUDO} rm -rf /var/log/*pihole* &> /dev/null
|
||||||
|
${SUDO} rm -rf /var/log/pihole/*pihole* &> /dev/null
|
||||||
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
||||||
${SUDO} rm -rf /etc/.pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/.pihole/ &> /dev/null
|
||||||
${SUDO} rm -rf /opt/pihole/ &> /dev/null
|
${SUDO} rm -rf /opt/pihole/ &> /dev/null
|
||||||
|
|
|
@ -187,12 +187,12 @@ Available commands and options:
|
||||||
|
|
||||||
(Logging options):
|
(Logging options):
|
||||||
.br
|
.br
|
||||||
on Enable the Pi-hole log at /var/log/pihole.log
|
on Enable the Pi-hole log at /var/log/pihole/pihole.log
|
||||||
.br
|
.br
|
||||||
off Disable and flush the Pi-hole log at
|
off Disable and flush the Pi-hole log at
|
||||||
/var/log/pihole.log
|
/var/log/pihole/pihole.log
|
||||||
.br
|
.br
|
||||||
off noflush Disable the Pi-hole log at /var/log/pihole.log
|
off noflush Disable the Pi-hole log at /var/log/pihole/pihole.log
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-up, updatePihole\fR [--check-only]
|
\fB-up, updatePihole\fR [--check-only]
|
||||||
|
|
8
pihole
8
pihole
|
@ -254,9 +254,9 @@ Example: 'pihole logging on'
|
||||||
Specify whether the Pi-hole log should be used
|
Specify whether the Pi-hole log should be used
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
on Enable the Pi-hole log at /var/log/pihole.log
|
on Enable the Pi-hole log at /var/log/pihole/pihole.log
|
||||||
off Disable and flush the Pi-hole log at /var/log/pihole.log
|
off Disable and flush the Pi-hole log at /var/log/pihole/pihole.log
|
||||||
off noflush Disable the Pi-hole log at /var/log/pihole.log"
|
off noflush Disable the Pi-hole log at /var/log/pihole/pihole.log"
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ "${1}" == "off" ]]; then
|
elif [[ "${1}" == "off" ]]; then
|
||||||
# Disable logging
|
# Disable logging
|
||||||
|
@ -382,7 +382,7 @@ tailFunc() {
|
||||||
# Color blocklist/blacklist/wildcard entries as red
|
# Color blocklist/blacklist/wildcard entries as red
|
||||||
# Color A/AAAA/DHCP strings as white
|
# Color A/AAAA/DHCP strings as white
|
||||||
# Color everything else as gray
|
# Color everything else as gray
|
||||||
tail -f /var/log/pihole.log | grep --line-buffered "${1}" | sed -E \
|
tail -f /var/log/pihole/pihole.log | grep --line-buffered "${1}" | sed -E \
|
||||||
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
-e "s,($(date +'%b %d ')| dnsmasq\[[0-9]*\]),,g" \
|
||||||
-e "s,(.*(blacklisted |gravity blocked ).*),${COL_RED}&${COL_NC}," \
|
-e "s,(.*(blacklisted |gravity blocked ).*),${COL_RED}&${COL_NC}," \
|
||||||
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
-e "s,.*(query\\[A|DHCP).*,${COL_NC}&${COL_NC}," \
|
||||||
|
|
|
@ -905,23 +905,6 @@ def test_FTL_binary_installed_and_responsive_no_errors(host):
|
||||||
assert expected_stdout in installed_binary.stdout
|
assert expected_stdout in installed_binary.stdout
|
||||||
|
|
||||||
|
|
||||||
# def test_FTL_support_files_installed(host):
|
|
||||||
# '''
|
|
||||||
# confirms FTL support files are installed
|
|
||||||
# '''
|
|
||||||
# support_files = host.run('''
|
|
||||||
# source /opt/pihole/basic-install.sh
|
|
||||||
# FTLdetect
|
|
||||||
# stat -c '%a %n' /var/log/pihole-FTL.log
|
|
||||||
# stat -c '%a %n' /run/pihole-FTL.port
|
|
||||||
# stat -c '%a %n' /run/pihole-FTL.pid
|
|
||||||
# ls -lac /run
|
|
||||||
# ''')
|
|
||||||
# assert '644 /run/pihole-FTL.port' in support_files.stdout
|
|
||||||
# assert '644 /run/pihole-FTL.pid' in support_files.stdout
|
|
||||||
# assert '644 /var/log/pihole-FTL.log' in support_files.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_IPv6_only_link_local(host):
|
def test_IPv6_only_link_local(host):
|
||||||
'''
|
'''
|
||||||
confirms IPv6 blocking is disabled for Link-local address
|
confirms IPv6 blocking is disabled for Link-local address
|
||||||
|
|
Loading…
Reference in a new issue