Pi-hole Core v6.1.1 (#6267)

This commit is contained in:
Dan Schaper 2025-06-01 18:35:19 -07:00 committed by GitHub
commit ec892ec096
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 32 additions and 61 deletions

View File

@ -20,13 +20,6 @@ utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# shellcheck source=./advanced/Scripts/utils.sh # shellcheck source=./advanced/Scripts/utils.sh
source "${utilsfile}" source "${utilsfile}"
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
SKIP_INSTALL="true"
# shellcheck source="./automated install/basic-install.sh"
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
# stop_service() is defined in basic-install.sh
# restart_service() is defined in basic-install.sh
# Determine database location # Determine database location
DBFILE=$(getFTLConfigValue "files.database") DBFILE=$(getFTLConfigValue "files.database")
if [ -z "$DBFILE" ]; then if [ -z "$DBFILE" ]; then
@ -40,7 +33,7 @@ flushARP(){
fi fi
# Stop FTL to prevent database access # Stop FTL to prevent database access
if ! output=$(stop_service pihole-FTL 2>&1); then if ! output=$(service pihole-FTL stop 2>&1); then
echo -e "${OVER} ${CROSS} Failed to stop FTL" echo -e "${OVER} ${CROSS} Failed to stop FTL"
echo " Output: ${output}" echo " Output: ${output}"
return 1 return 1
@ -72,7 +65,7 @@ flushARP(){
fi fi
# Start FTL again # Start FTL again
if ! output=$(restart_service pihole-FTL 2>&1); then if ! output=$(service pihole-FTL restart 2>&1); then
echo -e "${OVER} ${CROSS} Failed to restart FTL" echo -e "${OVER} ${CROSS} Failed to restart FTL"
echo " Output: ${output}" echo " Output: ${output}"
return 1 return 1

View File

@ -17,12 +17,6 @@ utilsfile="${PI_HOLE_SCRIPT_DIR}/utils.sh"
# shellcheck source="./advanced/Scripts/utils.sh" # shellcheck source="./advanced/Scripts/utils.sh"
source "${utilsfile}" source "${utilsfile}"
SKIP_INSTALL="true"
# shellcheck source="./automated install/basic-install.sh"
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
# stop_service() is defined in basic-install.sh
# restart_service() is defined in basic-install.sh
# In case we're running at the same time as a system logrotate, use a # 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 # separate logrotate state file to prevent stepping on each other's
# toes. # toes.
@ -110,14 +104,13 @@ else
fi fi
# Stop FTL to make sure it doesn't write to the database while we're deleting data # Stop FTL to make sure it doesn't write to the database while we're deleting data
stop_service pihole-FTL >/dev/null service pihole-FTL stop
# 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)
deleted=$(pihole-FTL sqlite3 -ni "${DBFILE}" "DELETE FROM query_storage WHERE timestamp >= strftime('%s','now')-86400; select changes() from query_storage limit 1") 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 # Restart FTL
restart_service pihole-FTL >/dev/null service pihole-FTL restart
if [[ "$*" != *"quiet"* ]]; then if [[ "$*" != *"quiet"* ]]; then
echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database" echo -e "${OVER} ${TICK} Deleted ${deleted} queries from long-term query database"
fi fi

View File

@ -231,15 +231,6 @@ is_command() {
command -v "${check_command}" >/dev/null 2>&1 command -v "${check_command}" >/dev/null 2>&1
} }
is_pid1() {
# Checks to see if the given command runs as PID 1
local is_pid1="$1"
# select PID 1, format output to show only CMD column without header
# quietly grep for a match on the function passed parameter
ps --pid 1 --format comm= | grep -q "${is_pid1}"
}
# Compatibility # Compatibility
package_manager_detect() { package_manager_detect() {
@ -1164,7 +1155,7 @@ installConfigs() {
fi fi
# Install pihole-FTL systemd or init.d service, based on whether systemd is the init system or not # Install pihole-FTL systemd or init.d service, based on whether systemd is the init system or not
if is_pid1 systemd; then if ps -p 1 -o comm= | grep -q systemd; then
install -T -m 0644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.systemd" '/etc/systemd/system/pihole-FTL.service' install -T -m 0644 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.systemd" '/etc/systemd/system/pihole-FTL.service'
# Remove init.d service if present # Remove init.d service if present
@ -1232,12 +1223,9 @@ stop_service() {
# Can softfail, as process may not be installed when this is called # Can softfail, as process may not be installed when this is called
local str="Stopping ${1} service" local str="Stopping ${1} service"
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# If systemd is PID 1, if is_command systemctl; then
if is_pid1 systemd; then
# use that to restart the service
systemctl -q stop "${1}" || true systemctl -q stop "${1}" || true
else else
# Otherwise, fall back to the service command
service "${1}" stop >/dev/null || true service "${1}" stop >/dev/null || true
fi fi
printf "%b %b %s...\\n" "${OVER}" "${TICK}" "${str}" printf "%b %b %s...\\n" "${OVER}" "${TICK}" "${str}"
@ -1248,8 +1236,8 @@ restart_service() {
# Local, named variables # Local, named variables
local str="Restarting ${1} service" local str="Restarting ${1} service"
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# If systemd is PID 1, # If systemctl exists,
if is_pid1 systemd; then if is_command systemctl; then
# use that to restart the service # use that to restart the service
systemctl -q restart "${1}" systemctl -q restart "${1}"
else else
@ -1264,8 +1252,8 @@ enable_service() {
# Local, named variables # Local, named variables
local str="Enabling ${1} service to start on reboot" local str="Enabling ${1} service to start on reboot"
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# If systemd is PID1, # If systemctl exists,
if is_pid1 systemd; then if is_command systemctl; then
# use that to enable the service # use that to enable the service
systemctl -q enable "${1}" systemctl -q enable "${1}"
else else
@ -1280,8 +1268,8 @@ disable_service() {
# Local, named variables # Local, named variables
local str="Disabling ${1} service" local str="Disabling ${1} service"
printf " %b %s..." "${INFO}" "${str}" printf " %b %s..." "${INFO}" "${str}"
# If systemd is PID1, # If systemctl exists,
if is_pid1 systemd; then if is_command systemctl; then
# use that to disable the service # use that to disable the service
systemctl -q disable "${1}" systemctl -q disable "${1}"
else else
@ -1292,8 +1280,8 @@ disable_service() {
} }
check_service_active() { check_service_active() {
# If systemd is PID1, # If systemctl exists,
if is_pid1 systemd; then if is_command systemctl; then
# use that to check the status of the service # use that to check the status of the service
systemctl -q is-enabled "${1}" 2>/dev/null systemctl -q is-enabled "${1}" 2>/dev/null
else else

View File

@ -13,11 +13,6 @@ source "/opt/pihole/COL_TABLE"
# shellcheck source="./advanced/Scripts/utils.sh" # shellcheck source="./advanced/Scripts/utils.sh"
source "/opt/pihole/utils.sh" source "/opt/pihole/utils.sh"
SKIP_INSTALL="true"
# shellcheck source="./automated install/basic-install.sh"
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
# stop_service() is defined in basic-install.sh
ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome") ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
readonly ADMIN_INTERFACE_DIR readonly ADMIN_INTERFACE_DIR
@ -107,7 +102,11 @@ removePiholeFiles() {
# Remove FTL # Remove FTL
if command -v pihole-FTL &> /dev/null; then if command -v pihole-FTL &> /dev/null; then
echo -ne " ${INFO} Removing pihole-FTL..." echo -ne " ${INFO} Removing pihole-FTL..."
stop_service pihole-FTL if [[ -x "$(command -v systemctl)" ]]; then
systemctl stop pihole-FTL
else
service pihole-FTL stop
fi
${SUDO} rm -f /etc/systemd/system/pihole-FTL.service ${SUDO} rm -f /etc/systemd/system/pihole-FTL.service
if [[ -d '/etc/systemd/system/pihole-FTL.service.d' ]]; then if [[ -d '/etc/systemd/system/pihole-FTL.service.d' ]]; then
read -rp " ${QST} FTL service override directory /etc/systemd/system/pihole-FTL.service.d detected. Do you wish to remove this from your system? [y/N] " answer read -rp " ${QST} FTL service override directory /etc/systemd/system/pihole-FTL.service.d detected. Do you wish to remove this from your system? [y/N] " answer

2
pihole
View File

@ -389,8 +389,8 @@ tailFunc() {
echo -e " ${INFO} Press Ctrl-C to exit" echo -e " ${INFO} Press Ctrl-C to exit"
# Get logfile path # Get logfile path
readonly LOGFILE
LOGFILE=$(getFTLConfigValue files.log.dnsmasq) LOGFILE=$(getFTLConfigValue files.log.dnsmasq)
readonly LOGFILE
# Strip date from each line # Strip date from each line
# Color blocklist/denylist/wildcard entries as red # Color blocklist/denylist/wildcard entries as red

View File

@ -1,7 +1,7 @@
FROM quay.io/centos/centos:stream10 FROM quay.io/centos/centos:stream10
# Disable SELinux # Disable SELinux
RUN echo "SELINUX=disabled" > /etc/selinux/config RUN echo "SELINUX=disabled" > /etc/selinux/config
RUN yum install -y --allowerasing curl git RUN yum install -y --allowerasing curl git initscripts
ENV GITDIR=/etc/.pihole ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole ENV SCRIPTDIR=/opt/pihole

View File

@ -1,7 +1,7 @@
FROM quay.io/centos/centos:stream9 FROM quay.io/centos/centos:stream9
# Disable SELinux # Disable SELinux
RUN echo "SELINUX=disabled" > /etc/selinux/config RUN echo "SELINUX=disabled" > /etc/selinux/config
RUN yum install -y --allowerasing curl git RUN yum install -y --allowerasing curl git initscripts
ENV GITDIR=/etc/.pihole ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:40 FROM fedora:40
RUN dnf install -y git RUN dnf install -y git initscripts
ENV GITDIR=/etc/.pihole ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:41 FROM fedora:41
RUN dnf install -y git RUN dnf install -y git initscripts
ENV GITDIR=/etc/.pihole ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole ENV SCRIPTDIR=/opt/pihole

View File

@ -1,5 +1,5 @@
FROM fedora:42 FROM fedora:42
RUN dnf install -y git gawk RUN dnf install -y git initscripts
ENV GITDIR=/etc/.pihole ENV GITDIR=/etc/.pihole
ENV SCRIPTDIR=/opt/pihole ENV SCRIPTDIR=/opt/pihole

View File

@ -66,14 +66,6 @@ def test_installPihole_fresh_install_readableFiles(host):
mock_command("dialog", {"*": ("", "0")}, host) mock_command("dialog", {"*": ("", "0")}, host)
# mock git pull # mock git pull
mock_command_passthrough("git", {"pull": ("", "0")}, host) mock_command_passthrough("git", {"pull": ("", "0")}, host)
# mock PID 1 to pretend to be systemd
mock_command_2(
"ps",
{
"--pid 1": ("systemd", "0"),
},
host,
)
# mock systemctl to not start FTL # mock systemctl to not start FTL
mock_command_2( mock_command_2(
"systemctl", "systemctl",
@ -81,7 +73,6 @@ def test_installPihole_fresh_install_readableFiles(host):
"enable pihole-FTL": ("", "0"), "enable pihole-FTL": ("", "0"),
"restart pihole-FTL": ("", "0"), "restart pihole-FTL": ("", "0"),
"start pihole-FTL": ("", "0"), "start pihole-FTL": ("", "0"),
"stop pihole-FTL": ("", "0"),
"*": ('echo "systemctl call with $@"', "0"), "*": ('echo "systemctl call with $@"', "0"),
}, },
host, host,
@ -140,6 +131,13 @@ def test_installPihole_fresh_install_readableFiles(host):
check_macvendor = test_cmd.format("r", "/etc/pihole/macvendor.db", piholeuser) check_macvendor = test_cmd.format("r", "/etc/pihole/macvendor.db", piholeuser)
actual_rc = host.run(check_macvendor).rc actual_rc = host.run(check_macvendor).rc
assert exit_status_success == actual_rc assert exit_status_success == actual_rc
# check readable and executable /etc/init.d/pihole-FTL
check_init = test_cmd.format("x", "/etc/init.d/pihole-FTL", piholeuser)
actual_rc = host.run(check_init).rc
assert exit_status_success == actual_rc
check_init = test_cmd.format("r", "/etc/init.d/pihole-FTL", piholeuser)
actual_rc = host.run(check_init).rc
assert exit_status_success == actual_rc
# check readable and executable manpages # check readable and executable manpages
if maninstalled is True: if maninstalled is True:
check_man = test_cmd.format("x", "/usr/local/share/man", piholeuser) check_man = test_cmd.format("x", "/usr/local/share/man", piholeuser)