Compare commits

..

17 Commits

Author SHA1 Message Date
Adam Warner 1837b754b9 v6.2.2 (#6447) 2025-10-28 17:07:28 +00:00
yubiuser d0fd967734 Bump github/codeql-action from 4.30.9 to 4.31.0 in the github-actions-dependencies group across 1 directory (#6446) 2025-10-28 16:08:39 +01:00
dependabot[bot] 4247a6056b Bump github/codeql-action
Bumps the github-actions-dependencies group with 1 update in the / directory: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 4.30.9 to 4.31.0
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/16140ae1a102900babc80a33c44059580f687047...4e94bd11f71e507f7f87df81788dff88d1dacbfb)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.31.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-28 13:43:44 +00:00
Adam Warner dff04eb822 Start using commented tags for editorconfig-checker (#6443) 2025-10-28 13:42:25 +00:00
Adam Warner c5a2078ce7 Add bind9-dnsutils as dependency for APT based systems (#6444) 2025-10-28 13:41:55 +00:00
Adam Warner 1d6b3cd894 Add log file path variables and ensure log files are created if missing (#6441) 2025-10-28 13:40:00 +00:00
Adam Warner 91727fe284 Create version file, if not existing (on first Container start) (#6440) 2025-10-27 20:57:50 +00:00
Christian König fc4c10dbe2 Add bind9-dnsutils as dependency for APT based systems
Signed-off-by: Christian König <github@yubiuser.dev>
2025-10-26 21:06:22 +01:00
yubiuser 0e46b9c83f Bump tox from 4.31.0 to 4.32.0 in /test in the python-dependencies group (#6433) 2025-10-26 20:50:56 +01:00
Christian König 49099d017a Start using commented tags for editorconfig-checker
Signed-off-by: Christian König <github@yubiuser.dev>
2025-10-26 20:30:34 +01:00
Yannick7777 72e3699265 Add log file path variables and ensure log files are created if missing
Signed-off-by: Yannick7777 <admin@eyer.life>
2025-10-26 15:19:56 +01:00
casperklein 1818e7e59e Ensure 'versions' file exist on first start
Signed-off-by: casperklein <casperklein@users.noreply.github.com>
2025-10-26 12:05:13 +01:00
Adam Warner 770aa1f061 Sync master back into development (#6434) 2025-10-25 11:49:52 +01:00
Adam Warner 66a3c73d6c Fix formatting in chooseInterface function (#6435) 2025-10-25 11:38:21 +01:00
Adam Warner 1ca693866c Fix formatting in chooseInterface function to ensure proper variable expansion - with quotes, the dialog command throws the error:
Expected at least 20 tokens for --radi, have 5.
Use --help to list options.

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
2025-10-25 11:31:59 +01:00
Adam Warner 75d4082e57 Pi-hole Core v6.2 (#6411) 2025-10-25 11:11:45 +01:00
dependabot[bot] 77dd566a4f Bump tox from 4.31.0 to 4.32.0 in /test in the python-dependencies group
Bumps the python-dependencies group in /test with 1 update: [tox](https://github.com/tox-dev/tox).


Updates `tox` from 4.31.0 to 4.32.0
- [Release notes](https://github.com/tox-dev/tox/releases)
- [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst)
- [Commits](https://github.com/tox-dev/tox/compare/4.31.0...4.32.0)

---
updated-dependencies:
- dependency-name: tox
  dependency-version: 4.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: python-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-25 10:01:46 +00:00
10 changed files with 88 additions and 135 deletions
+3 -3
View File
@@ -29,12 +29,12 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- -
name: Initialize CodeQL name: Initialize CodeQL
uses: github/codeql-action/init@16140ae1a102900babc80a33c44059580f687047 #v4.30.9 uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
with: with:
languages: 'python' languages: 'python'
- -
name: Autobuild name: Autobuild
uses: github/codeql-action/autobuild@16140ae1a102900babc80a33c44059580f687047 #v4.30.9 uses: github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
- -
name: Perform CodeQL Analysis name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@16140ae1a102900babc80a33c44059580f687047 #v4.30.9 uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
+1 -1
View File
@@ -43,7 +43,7 @@ jobs:
ignore_words_file: .codespellignore ignore_words_file: .codespellignore
- name: Get editorconfig-checker - name: Get editorconfig-checker
uses: editorconfig-checker/action-editorconfig-checker@5ecdd656fe347c26f76b1b435b90e1d74fb5e787 # tag v2. is really out of date uses: editorconfig-checker/action-editorconfig-checker@4b6cd6190d435e7e084fb35e36a096e98506f7b9 #v2.1.0
- name: Run editorconfig-checker - name: Run editorconfig-checker
run: editorconfig-checker run: editorconfig-checker
+60 -18
View File
@@ -17,6 +17,11 @@ utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# shellcheck source="./advanced/Scripts/utils.sh" # shellcheck source="./advanced/Scripts/utils.sh"
source "${utilsfile}" source "${utilsfile}"
# In case we're running at the same time as a system logrotate, use a
# separate logrotate state file to prevent stepping on each other's
# toes.
STATEFILE="/var/lib/logrotate/pihole"
# Determine database location # Determine database location
DBFILE=$(getFTLConfigValue "files.database") DBFILE=$(getFTLConfigValue "files.database")
if [ -z "$DBFILE" ]; then if [ -z "$DBFILE" ]; then
@@ -37,6 +42,25 @@ if [ -z "$WEBFILE" ]; then
WEBFILE="/var/log/pihole/webserver.log" WEBFILE="/var/log/pihole/webserver.log"
fi fi
# Helper function to handle log rotation for a single file
rotate_log() {
# This function copies x.log over to x.log.1
# and then empties x.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)
local logfile="$1"
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Rotating ${logfile} ..."
fi
cp -p "${logfile}" "${logfile}.1"
echo " " > "${logfile}"
chmod 640 "${logfile}"
if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Rotated ${logfile} ..."
fi
}
# Helper function to handle log flushing for a single file # Helper function to handle log flushing for a single file
flush_log() { flush_log() {
local logfile="$1" local logfile="$1"
@@ -54,23 +78,41 @@ flush_log() {
fi fi
} }
# Manual flushing if [[ "$*" == *"once"* ]]; then
flush_log "${LOGFILE}" # Nightly logrotation
flush_log "${FTLFILE}" if command -v /usr/sbin/logrotate >/dev/null; then
flush_log "${WEBFILE}" # Logrotate once
if [[ "$*" != *"quiet"* ]]; then if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Flushing database, DNS resolution temporarily unavailable ..." echo -ne " ${INFO} Running logrotate ..."
fi fi
mkdir -p "${STATEFILE%/*}"
# Stop FTL to make sure it doesn't write to the database while we're deleting data /usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
service pihole-FTL stop else
# Handle rotation for each log file
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history) rotate_log "${LOGFILE}"
deleted=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM query_storage WHERE timestamp >= strftime('%s','now')-86400; select changes() from query_storage limit 1") rotate_log "${FTLFILE}"
rotate_log "${WEBFILE}"
# Restart FTL fi
service pihole-FTL restart else
if [[ "$*" != *"quiet"* ]]; then # Manual flushing
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database" flush_log "${LOGFILE}"
flush_log "${FTLFILE}"
flush_log "${WEBFILE}"
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Flushing database, DNS resolution temporarily unavailable ..."
fi
# Stop FTL to make sure it doesn't write to the database while we're deleting data
service pihole-FTL stop
# Delete most recent 24 hours from FTL's database, leave even older data intact (don't wipe out all history)
deleted=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM query_storage WHERE timestamp >= strftime('%s','now')-86400; select changes() from query_storage limit 1")
# Restart FTL
service pihole-FTL restart
if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database"
fi
fi fi
-72
View File
@@ -1,72 +0,0 @@
#!/usr/bin/env bash
# Pi-hole: A black hole for Internet advertisements
# (c) 2025 Pi-hole, LLC (https://pi-hole.net)
# Network-wide ad blocking via your own hardware.
#
# Rotate 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.
colfile="/opt/pihole/COL_TABLE"
# shellcheck source="./advanced/Scripts/COL_TABLE"
source ${colfile}
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# shellcheck source="./advanced/Scripts/utils.sh"
source "${utilsfile}"
# In case we're running at the same time as a system logrotate, use a
# separate logrotate state file to prevent stepping on each other's
# toes.
STATEFILE="/var/lib/logrotate/pihole"
# Determine log file location
LOGFILE=$(getFTLConfigValue "files.log.dnsmasq")
if [ -z "$LOGFILE" ]; then
LOGFILE="/var/log/pihole/pihole.log"
fi
FTLFILE=$(getFTLConfigValue "files.log.ftl")
if [ -z "$FTLFILE" ]; then
FTLFILE="/var/log/pihole/FTL.log"
fi
WEBFILE=$(getFTLConfigValue "files.log.webserver")
if [ -z "$WEBFILE" ]; then
WEBFILE="/var/log/pihole/webserver.log"
fi
# Helper function to handle log rotation for a single file
rotate_log() {
# This function copies x.log over to x.log.1
# and then empties x.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)
local logfile="$1"
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Rotating ${logfile} ..."
fi
cp -p "${logfile}" "${logfile}.1"
echo " " > "${logfile}"
chmod 640 "${logfile}"
if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Rotated ${logfile} ..."
fi
}
# Nightly logrotation
if command -v /usr/sbin/logrotate >/dev/null; then
# Logrotate once
if [[ "$*" != *"quiet"* ]]; then
echo -ne " ${INFO} Running logrotate ..."
fi
mkdir -p "${STATEFILE%/*}"
/usr/sbin/logrotate --force --state "${STATEFILE}" /etc/pihole/logrotate
else
# Handle rotation for each log file
rotate_log "${LOGFILE}"
rotate_log "${FTLFILE}"
rotate_log "${WEBFILE}"
fi
+11 -3
View File
@@ -8,12 +8,20 @@ utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# Get file paths # Get file paths
FTL_PID_FILE="$(getFTLConfigValue files.pid)" FTL_PID_FILE="$(getFTLConfigValue files.pid)"
FTL_LOG_FILE="$(getFTLConfigValue files.log.ftl)"
PIHOLE_LOG_FILE="$(getFTLConfigValue files.log.dnsmasq)"
WEBSERVER_LOG_FILE="$(getFTLConfigValue files.log.webserver)"
FTL_PID_FILE="${FTL_PID_FILE:-/run/pihole-FTL.pid}"
FTL_LOG_FILE="${FTL_LOG_FILE:-/var/log/pihole/FTL.log}"
PIHOLE_LOG_FILE="${PIHOLE_LOG_FILE:-/var/log/pihole/pihole.log}"
WEBSERVER_LOG_FILE="${WEBSERVER_LOG_FILE:-/var/log/pihole/webserver.log}"
# 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
mkdir -p /var/log/pihole mkdir -p /var/log/pihole
chown -R pihole:pihole /etc/pihole/ /var/log/pihole/ chown -R pihole:pihole /etc/pihole/ /var/log/pihole/
# allow all users read version file (and use pihole -v) # allow all users read version file (and use pihole -v)
touch /etc/pihole/versions
chmod 0644 /etc/pihole/versions chmod 0644 /etc/pihole/versions
# allow pihole to access subdirs in /etc/pihole (sets execution bit on dirs) # allow pihole to access subdirs in /etc/pihole (sets execution bit on dirs)
@@ -28,7 +36,7 @@ chown root:root /etc/pihole/logrotate
# 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)
[ -f "${FTL_PID_FILE}" ] || install -D -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}" [ -f "${FTL_PID_FILE}" ] || install -D -m 644 -o pihole -g pihole /dev/null "${FTL_PID_FILE}"
[ -f /var/log/pihole/FTL.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/FTL.log [ -f "${FTL_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${FTL_LOG_FILE}"
[ -f /var/log/pihole/pihole.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/pihole.log [ -f "${PIHOLE_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${PIHOLE_LOG_FILE}"
[ -f /var/log/pihole/webserver.log ] || install -m 640 -o pihole -g pihole /dev/null /var/log/pihole/webserver.log [ -f "${WEBSERVER_LOG_FILE}" ] || install -m 640 -o pihole -g pihole /dev/null "${WEBSERVER_LOG_FILE}"
[ -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
+1 -1
View File
@@ -24,7 +24,7 @@
# The flush script will use logrotate if available # The flush script will use logrotate if available
# parameter "once": logrotate only once (default is twice) # parameter "once": logrotate only once (default is twice)
# parameter "quiet": don't print messages # parameter "quiet": don't print messages
00 00 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole logrotate quiet 00 00 * * * root PATH="$PATH:/usr/sbin:/usr/local/bin/" pihole flush once quiet
@reboot root /usr/sbin/logrotate --state /var/lib/logrotate/pihole /etc/pihole/logrotate @reboot root /usr/sbin/logrotate --state /var/lib/logrotate/pihole /etc/pihole/logrotate
+5 -4
View File
@@ -84,7 +84,7 @@ webInterfaceDir="${webroot}/admin"
piholeGitUrl="https://github.com/pi-hole/pi-hole.git" piholeGitUrl="https://github.com/pi-hole/pi-hole.git"
PI_HOLE_LOCAL_REPO="/etc/.pihole" PI_HOLE_LOCAL_REPO="/etc/.pihole"
# List of pihole scripts, stored in an array # List of pihole scripts, stored in an array
PI_HOLE_FILES=(list piholeDebug piholeLogFlush piholeLogRotate setupLCD update version gravity uninstall webpage) PI_HOLE_FILES=(list piholeDebug piholeLogFlush setupLCD update version gravity uninstall webpage)
# This directory is where the Pi-hole scripts will be installed # This directory is where the Pi-hole scripts will be installed
PI_HOLE_INSTALL_DIR="/opt/pihole" PI_HOLE_INSTALL_DIR="/opt/pihole"
PI_HOLE_CONFIG_DIR="/etc/pihole" PI_HOLE_CONFIG_DIR="/etc/pihole"
@@ -116,11 +116,11 @@ c=70
PIHOLE_META_PACKAGE_CONTROL_APT=$( PIHOLE_META_PACKAGE_CONTROL_APT=$(
cat <<EOM cat <<EOM
Package: pihole-meta Package: pihole-meta
Version: 0.5 Version: 0.6
Maintainer: Pi-hole team <adblock@pi-hole.net> Maintainer: Pi-hole team <adblock@pi-hole.net>
Architecture: all Architecture: all
Description: Pi-hole dependency meta package Description: Pi-hole dependency meta package
Depends: awk,bash-completion,binutils,ca-certificates,cron|cron-daemon,curl,dialog,dnsutils,dns-root-data,git,grep,iproute2,iputils-ping,jq,libcap2,libcap2-bin,lshw,procps,psmisc,sudo,unzip Depends: awk,bash-completion,binutils,ca-certificates,cron|cron-daemon,curl,dialog,bind9-dnsutils|dnsutils,dns-root-data,git,grep,iproute2,iputils-ping,jq,libcap2,libcap2-bin,lshw,procps,psmisc,sudo,unzip
Section: contrib/metapackages Section: contrib/metapackages
Priority: optional Priority: optional
EOM EOM
@@ -694,10 +694,11 @@ chooseInterface() {
status="OFF" status="OFF"
done done
# Disable check for double quote here as we are passing a string with spaces # Disable check for double quote here as we are passing a string with spaces
# shellcheck disable=SC2086
PIHOLE_INTERFACE=$(dialog --no-shadow --keep-tite --output-fd 1 \ PIHOLE_INTERFACE=$(dialog --no-shadow --keep-tite --output-fd 1 \
--cancel-label "Exit" --ok-label "Select" \ --cancel-label "Exit" --ok-label "Select" \
--radiolist "Choose An Interface (press space to toggle selection)" \ --radiolist "Choose An Interface (press space to toggle selection)" \
${r} ${c} "${interfaceCount}" "${interfacesList}") ${r} ${c} "${interfaceCount}" ${interfacesList})
result=$? result=$?
case ${result} in case ${result} in
+2 -13
View File
@@ -100,12 +100,9 @@ Available commands and options:
-c Include a Pi-hole database integrity check -c Include a Pi-hole database integrity check
.br .br
\fB-f, flush\fR [quite] \fB-f, flush\fR
.br .br
Flush the Pi-hole log and last 24h from the query database Flush the Pi-hole log
.br
quite Suppress output
.br .br
\fB-r, repair\fR \fB-r, repair\fR
@@ -245,14 +242,6 @@ Available commands and options:
verbose Show authentication and status messages verbose Show authentication and status messages
.br .br
\fBlogrotate\fR [quite]
.br
Rotate Pi-hole's log files
.br
quite Suppress output
.br
.SH "EXAMPLE" .SH "EXAMPLE"
Some usage examples Some usage examples
+4 -19
View File
@@ -92,13 +92,8 @@ debugFunc() {
} }
flushFunc() { flushFunc() {
# unsupported in docker because it requires restarting FTL "${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh "$@"
if [ -n "${DOCKER_VERSION}" ]; then exit 0
unsupportedFunc
else
"${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh "$@"
exit 0
fi
} }
# Deprecated function, should be removed in the future # Deprecated function, should be removed in the future
@@ -110,11 +105,6 @@ arpFunc() {
exit 0 exit 0
} }
logrotateFunc() {
"${PI_HOLE_SCRIPT_DIR}"/piholeLogRotate.sh "$@"
exit 0
}
networkFlush() { networkFlush() {
shift shift
"${PI_HOLE_SCRIPT_DIR}"/piholeNetworkFlush.sh "$@" "${PI_HOLE_SCRIPT_DIR}"/piholeNetworkFlush.sh "$@"
@@ -512,8 +502,7 @@ Debugging Options:
-d, debug Start a debugging session -d, debug Start a debugging session
Add '-c' or '--check-database' to include a Pi-hole database integrity check Add '-c' or '--check-database' to include a Pi-hole database integrity check
Add '-a' to automatically upload the log to tricorder.pi-hole.net Add '-a' to automatically upload the log to tricorder.pi-hole.net
-f, flush Flush the Pi-hole logs and last 24h from the query database -f, flush Flush the Pi-hole log
Add 'quiet' to suppress output messages
-r, repair Repair Pi-hole subsystems -r, repair Repair Pi-hole subsystems
-t, tail [arg] View the live output of the Pi-hole log. -t, tail [arg] View the live output of the Pi-hole log.
Add an optional argument to filter the log Add an optional argument to filter the log
@@ -546,9 +535,7 @@ Options:
checkout Switch Pi-hole subsystems to a different GitHub branch checkout Switch Pi-hole subsystems to a different GitHub branch
Add '-h' for more info on checkout usage Add '-h' for more info on checkout usage
networkflush Flush information stored in Pi-hole's network tables networkflush Flush information stored in Pi-hole's network tables
Add '--arp' to additionally flush the ARP table Add '--arp' to additionally flush the ARP table ";
logrotate Rotate Pi-hole's log files
Add 'quiet' to suppress output messages";
exit 0 exit 0
} }
@@ -591,7 +578,6 @@ case "${1}" in
"arpflush" ) need_root=true;; # Deprecated, use networkflush instead "arpflush" ) need_root=true;; # Deprecated, use networkflush instead
"networkflush" ) need_root=true;; "networkflush" ) need_root=true;;
"-t" | "tail" ) need_root=true;; "-t" | "tail" ) need_root=true;;
"logrotate" ) need_root=true;;
* ) helpFunc;; * ) helpFunc;;
esac esac
@@ -627,6 +613,5 @@ case "${1}" in
"arpflush" ) arpFunc "$@";; # Deprecated, use networkflush instead "arpflush" ) arpFunc "$@";; # Deprecated, use networkflush instead
"networkflush" ) networkFlush "$@";; "networkflush" ) networkFlush "$@";;
"-t" | "tail" ) tailFunc "$2";; "-t" | "tail" ) tailFunc "$2";;
"logrotate" ) logrotateFunc "$@";;
* ) helpFunc;; * ) helpFunc;;
esac esac
+1 -1
View File
@@ -2,5 +2,5 @@ pyyaml == 6.0.3
pytest == 8.4.2 pytest == 8.4.2
pytest-xdist == 3.8.0 pytest-xdist == 3.8.0
pytest-testinfra == 10.2.2 pytest-testinfra == 10.2.2
tox == 4.31.0 tox == 4.32.0
pytest-clarity == 1.0.1 pytest-clarity == 1.0.1