Merge branch 'master' into unsupported/binary
Some checks are pending
Check for merge conflicts / main (push) Waiting to run
CodeQL / Analyze (pull_request) Waiting to run
Test Supported Distributions / smoke-tests (pull_request) Waiting to run
Test Supported Distributions / distro-test (alpine_3_21) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_23) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_10) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_9) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_11) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_12) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_13) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_40) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_41) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_42) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_43) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_20) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_24) (pull_request) Blocked by required conditions
Check for merge conflicts / main (pull_request_target) Waiting to run
Some checks are pending
Check for merge conflicts / main (push) Waiting to run
CodeQL / Analyze (pull_request) Waiting to run
Test Supported Distributions / smoke-tests (pull_request) Waiting to run
Test Supported Distributions / distro-test (alpine_3_21) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (alpine_3_23) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_10) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (centos_9) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_11) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_12) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (debian_13) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_40) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_41) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_42) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (fedora_43) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_20) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_22) (pull_request) Blocked by required conditions
Test Supported Distributions / distro-test (ubuntu_24) (pull_request) Blocked by required conditions
Check for merge conflicts / main (pull_request_target) Waiting to run
This commit is contained in:
@@ -94,8 +94,8 @@ fresh_install=true
|
||||
|
||||
adlistFile="/etc/pihole/adlists.list"
|
||||
# Pi-hole needs an IP address; to begin, these variables are empty since we don't know what the IP is until this script can run
|
||||
IPV4_ADDRESS=${IPV4_ADDRESS}
|
||||
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||
IPV4_ADDRESS=
|
||||
IPV6_ADDRESS=
|
||||
# Give settings their default values. These may be changed by prompts later in the script.
|
||||
QUERY_LOGGING=
|
||||
PRIVACY_LEVEL=
|
||||
@@ -116,11 +116,11 @@ c=70
|
||||
PIHOLE_META_PACKAGE_CONTROL_APT=$(
|
||||
cat <<EOM
|
||||
Package: pihole-meta
|
||||
Version: 0.4
|
||||
Version: 0.6
|
||||
Maintainer: Pi-hole team <adblock@pi-hole.net>
|
||||
Architecture: all
|
||||
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,netcat-openbsd,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
|
||||
Priority: optional
|
||||
EOM
|
||||
@@ -130,12 +130,12 @@ EOM
|
||||
PIHOLE_META_PACKAGE_CONTROL_RPM=$(
|
||||
cat <<EOM
|
||||
Name: pihole-meta
|
||||
Version: 0.2
|
||||
Version: 0.3
|
||||
Release: 1
|
||||
License: EUPL
|
||||
BuildArch: noarch
|
||||
Summary: Pi-hole dependency meta package
|
||||
Requires: bash-completion,bind-utils,binutils,ca-certificates,chkconfig,cronie,curl,dialog,findutils,gawk,git,grep,iproute,jq,libcap,lshw,nmap-ncat,procps-ng,psmisc,sudo,unzip
|
||||
Requires: bash-completion,bind-utils,binutils,ca-certificates,chkconfig,cronie,curl,dialog,findutils,gawk,git,grep,iproute,jq,libcap,lshw,procps-ng,psmisc,sudo,unzip
|
||||
%description
|
||||
Pi-hole dependency meta package
|
||||
%prep
|
||||
@@ -143,6 +143,9 @@ Pi-hole dependency meta package
|
||||
%files
|
||||
%install
|
||||
%changelog
|
||||
* Mon Jul 14 2025 Pi-hole Team - 0.3
|
||||
- Remove nmap-ncat from the list of dependencies
|
||||
|
||||
* Wed May 28 2025 Pi-hole Team - 0.2
|
||||
- Add gawk to the list of dependencies
|
||||
|
||||
@@ -151,6 +154,35 @@ Pi-hole dependency meta package
|
||||
EOM
|
||||
)
|
||||
|
||||
# List of required packages on APK based systems
|
||||
PIHOLE_META_VERSION_APK=0.2
|
||||
PIHOLE_META_DEPS_APK=(
|
||||
bash
|
||||
bash-completion
|
||||
bind-tools
|
||||
binutils
|
||||
coreutils
|
||||
cronie
|
||||
curl
|
||||
dialog
|
||||
git
|
||||
grep
|
||||
iproute2-minimal # piholeARPTable.sh
|
||||
iproute2-ss # piholeDebug.sh
|
||||
jq
|
||||
libcap
|
||||
logrotate
|
||||
lscpu # piholeDebug.sh
|
||||
lshw # piholeDebug.sh
|
||||
ncurses
|
||||
procps-ng
|
||||
psmisc
|
||||
shadow
|
||||
sudo
|
||||
tzdata
|
||||
unzip
|
||||
)
|
||||
|
||||
######## Undocumented Flags. Shhh ########
|
||||
# These are undocumented flags; some of which we can use when repairing an installation
|
||||
# The runUnattended flag is one example of this
|
||||
@@ -159,13 +191,24 @@ runUnattended=false
|
||||
skipFTL=false
|
||||
# Check arguments for the undocumented flags
|
||||
for var in "$@"; do
|
||||
case "$var" in
|
||||
case "${var}" in
|
||||
"--repair") repair=true ;;
|
||||
"--unattended") runUnattended=true ;;
|
||||
"--skipFTL") skipFTL=true ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${runUnattended}" == true ]]; then
|
||||
# In order to run an unattended setup, a pre-seeded /etc/pihole/pihole.toml must exist
|
||||
if [[ ! -f "${PI_HOLE_CONFIG_DIR}/pihole.toml" ]]; then
|
||||
printf " %b Error: \"%s\" not found. Cannot run unattended setup\\n" "${CROSS}" "${PI_HOLE_CONFIG_DIR}/pihole.toml"
|
||||
exit 1
|
||||
fi
|
||||
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
||||
# also disable debconf-apt-progress dialogs
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
fi
|
||||
|
||||
# If the color table file exists,
|
||||
if [[ -f "${coltable}" ]]; then
|
||||
# source it
|
||||
@@ -270,7 +313,15 @@ package_manager_detect() {
|
||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||
# The command we will use to remove packages (used in the uninstaller)
|
||||
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
||||
# If neither apt-get or yum/dnf package managers were found
|
||||
|
||||
# If neither apt-get or yum/dnf package managers were found, check for apk.
|
||||
elif is_command apk; then
|
||||
PKG_MANAGER="apk"
|
||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||
PKG_INSTALL="${PKG_MANAGER} add"
|
||||
PKG_COUNT="${PKG_MANAGER} list --upgradable -q | wc -l"
|
||||
PKG_REMOVE="${PKG_MANAGER} del"
|
||||
|
||||
else
|
||||
# we cannot install required packages
|
||||
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||
@@ -281,13 +332,20 @@ package_manager_detect() {
|
||||
|
||||
build_dependency_package(){
|
||||
# This function will build a package that contains all the dependencies needed for Pi-hole
|
||||
if is_command apk ; then
|
||||
local str="APK based system detected. Dependencies will be installed using a virtual package named pihole-meta"
|
||||
printf " %b %s...\\n" "${INFO}" "${str}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# remove any leftover build directory that may exist
|
||||
rm -rf /tmp/pihole-meta_*
|
||||
|
||||
# Create a fresh build directory with random name
|
||||
# Busybox Compat: `mktemp` long flags unsupported
|
||||
# -d flag is short form of --directory
|
||||
local tempdir
|
||||
tempdir="$(mktemp --directory /tmp/pihole-meta_XXXXX)"
|
||||
tempdir="$(mktemp -d /tmp/pihole-meta_XXXXX)"
|
||||
chmod 0755 "${tempdir}"
|
||||
|
||||
if is_command apt-get; then
|
||||
@@ -575,14 +633,17 @@ Do you wish to continue with an IPv6-only installation?\\n\\n" \
|
||||
;;
|
||||
esac
|
||||
|
||||
DNS_SERVERS="$DNS_SERVERS_IPV6_ONLY"
|
||||
DNS_SERVERS="${DNS_SERVERS_IPV6_ONLY}"
|
||||
printf " %b Proceeding with IPv6 only installation.\\n" "${INFO}"
|
||||
}
|
||||
|
||||
# Get available interfaces that are UP
|
||||
get_available_interfaces() {
|
||||
# There may be more than one so it's all stored in a variable
|
||||
availableInterfaces=$(ip --oneline link show up | awk '{print $2}' | grep -v "^lo" | cut -d':' -f1 | cut -d'@' -f1)
|
||||
# The ip command list all interfaces that are in the up state
|
||||
# The awk command filters out any interfaces that have the LOOPBACK flag set
|
||||
# while using the characters ": " or "@" as a field separator for awk
|
||||
availableInterfaces=$(ip --oneline link show up | awk -F ': |@' '!/<.*LOOPBACK.*>/ {print $2}')
|
||||
}
|
||||
|
||||
# A function for displaying the dialogs the user sees when first running the installer
|
||||
@@ -645,6 +706,7 @@ chooseInterface() {
|
||||
status="OFF"
|
||||
done
|
||||
# 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 \
|
||||
--cancel-label "Exit" --ok-label "Select" \
|
||||
--radiolist "Choose An Interface (press space to toggle selection)" \
|
||||
@@ -670,9 +732,9 @@ testIPv6() {
|
||||
# first will contain fda2 (ULA)
|
||||
printf -v first "%s" "${1%%:*}"
|
||||
# value1 will contain 253 which is the decimal value corresponding to 0xFD
|
||||
value1=$(((0x$first) / 256))
|
||||
value1=$(((0x${first}) / 256))
|
||||
# value2 will contain 162 which is the decimal value corresponding to 0xA2
|
||||
value2=$(((0x$first) % 256))
|
||||
value2=$(((0x${first}) % 256))
|
||||
# the ULA test is testing for fc00::/7 according to RFC 4193
|
||||
if (((value1 & 254) == 252)); then
|
||||
# echoing result to calling function as return value
|
||||
@@ -697,7 +759,7 @@ find_IPv6_information() {
|
||||
# For each address in the array above, determine the type of IPv6 address it is
|
||||
for i in "${IPV6_ADDRESSES[@]}"; do
|
||||
# Check if it's ULA, GUA, or LL by using the function created earlier
|
||||
result=$(testIPv6 "$i")
|
||||
result=$(testIPv6 "${i}")
|
||||
# If it's a ULA address, use it and store it as a global variable
|
||||
[[ "${result}" == "ULA" ]] && ULA_ADDRESS="${i%/*}"
|
||||
# If it's a GUA address, use it and store it as a global variable
|
||||
@@ -732,7 +794,7 @@ collect_v4andv6_information() {
|
||||
printf " %b IPv4 address: %s\\n" "${INFO}" "${IPV4_ADDRESS}"
|
||||
find_IPv6_information
|
||||
printf " %b IPv6 address: %s\\n" "${INFO}" "${IPV6_ADDRESS}"
|
||||
if [ "$IPV4_ADDRESS" == "" ] && [ "$IPV6_ADDRESS" != "" ]; then
|
||||
if [ "${IPV4_ADDRESS}" == "" ] && [ "${IPV6_ADDRESS}" != "" ]; then
|
||||
confirm_ipv6_only
|
||||
fi
|
||||
}
|
||||
@@ -752,7 +814,7 @@ valid_ip() {
|
||||
local regex="^${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}\\.${ipv4elem}${portelem}$"
|
||||
|
||||
# Evaluate the regex, and return the result
|
||||
[[ $ip =~ ${regex} ]]
|
||||
[[ ${ip} =~ ${regex} ]]
|
||||
|
||||
stat=$?
|
||||
return "${stat}"
|
||||
@@ -787,7 +849,7 @@ setDNS() {
|
||||
DNSChooseOptions=()
|
||||
local DNSServerCount=0
|
||||
# Save the old Internal Field Separator in a variable,
|
||||
OIFS=$IFS
|
||||
OIFS=${IFS}
|
||||
# and set the new one to newline
|
||||
IFS=$'\n'
|
||||
# Put the DNS Servers into an array
|
||||
@@ -855,7 +917,7 @@ If you want to specify a port other than 53, separate it with a hash.\
|
||||
esac
|
||||
|
||||
# Clean user input and replace whitespace with comma.
|
||||
piholeDNS=$(sed 's/[, \t]\+/,/g' <<<"${piholeDNS}")
|
||||
piholeDNS="${piholeDNS//[[:blank:]]/,}"
|
||||
|
||||
# Separate the user input into the two DNS values (separated by a comma)
|
||||
printf -v PIHOLE_DNS_1 "%s" "${piholeDNS%%,*}"
|
||||
@@ -911,7 +973,7 @@ If you want to specify a port other than 53, separate it with a hash.\
|
||||
done
|
||||
else
|
||||
# Save the old Internal Field Separator in a variable,
|
||||
OIFS=$IFS
|
||||
OIFS=${IFS}
|
||||
# and set the new one to newline
|
||||
IFS=$'\n'
|
||||
for DNSServer in ${DNS_SERVERS}; do
|
||||
@@ -1133,7 +1195,8 @@ installScripts() {
|
||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./automated\ install/uninstall.sh
|
||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_INSTALL_DIR}" ./advanced/Scripts/COL_TABLE
|
||||
install -o "${USER}" -Dm755 -t "${PI_HOLE_BIN_DIR}" pihole
|
||||
install -Dm644 ./advanced/bash-completion/pihole /etc/bash_completion.d/pihole
|
||||
install -Dm644 ./advanced/bash-completion/pihole.bash /etc/bash_completion.d/pihole
|
||||
install -Dm644 ./advanced/bash-completion/pihole-ftl.bash /etc/bash_completion.d/pihole-FTL
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
|
||||
else
|
||||
@@ -1172,7 +1235,12 @@ installConfigs() {
|
||||
# Load final service
|
||||
systemctl daemon-reload
|
||||
else
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.service" '/etc/init.d/pihole-FTL'
|
||||
local INIT="service"
|
||||
if is_command openrc; then
|
||||
INIT="openrc"
|
||||
fi
|
||||
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL.${INIT}" '/etc/init.d/pihole-FTL'
|
||||
fi
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-prestart.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-prestart.sh"
|
||||
install -T -m 0755 "${PI_HOLE_LOCAL_REPO}/advanced/Templates/pihole-FTL-poststop.sh" "${PI_HOLE_INSTALL_DIR}/pihole-FTL-poststop.sh"
|
||||
@@ -1196,10 +1264,6 @@ install_manpage() {
|
||||
# if not present, create man8 directory
|
||||
install -d -m 755 /usr/local/share/man/man8
|
||||
fi
|
||||
if [[ ! -d "/usr/local/share/man/man5" ]]; then
|
||||
# if not present, create man5 directory
|
||||
install -d -m 755 /usr/local/share/man/man5
|
||||
fi
|
||||
# Testing complete, copy the files & update the man db
|
||||
install -D -m 644 -T ${PI_HOLE_LOCAL_REPO}/manpages/pihole.8 /usr/local/share/man/man8/pihole.8
|
||||
|
||||
@@ -1261,6 +1325,8 @@ enable_service() {
|
||||
if is_command systemctl; then
|
||||
# use that to enable the service
|
||||
systemctl -q enable "${1}"
|
||||
elif is_command openrc; then
|
||||
rc-update add "${1}" "${2:-default}" &> /dev/null
|
||||
else
|
||||
# Otherwise, use update-rc.d to accomplish this
|
||||
update-rc.d "${1}" defaults >/dev/null
|
||||
@@ -1276,7 +1342,10 @@ disable_service() {
|
||||
# If systemctl exists,
|
||||
if is_command systemctl; then
|
||||
# use that to disable the service
|
||||
systemctl -q disable "${1}"
|
||||
systemctl -q disable --now "${1}"
|
||||
elif is_command openrc; then
|
||||
rc-update del "${1}" "${2:-default}" &> /dev/null
|
||||
|
||||
else
|
||||
# Otherwise, use update-rc.d to accomplish this
|
||||
update-rc.d "${1}" disable >/dev/null
|
||||
@@ -1289,6 +1358,8 @@ check_service_active() {
|
||||
if is_command systemctl; then
|
||||
# use that to check the status of the service
|
||||
systemctl -q is-enabled "${1}" 2>/dev/null
|
||||
elif is_command openrc; then
|
||||
rc-status default boot | grep -q "${1}"
|
||||
else
|
||||
# Otherwise, fall back to service command
|
||||
service "${1}" status &>/dev/null
|
||||
@@ -1390,8 +1461,27 @@ install_dependent_packages() {
|
||||
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_RED}"
|
||||
return 1
|
||||
fi
|
||||
# Install Alpine packages
|
||||
elif is_command apk; then
|
||||
local repo_str="Ensuring alpine 'community' repo is enabled."
|
||||
printf "%b %b %s" "${OVER}" "${INFO}" "${repo_str}"
|
||||
|
||||
# If neither apt-get or yum/dnf package managers were found
|
||||
local pattern='^\s*#(.*/community/?)\s*$'
|
||||
sed -Ei "s:${pattern}:\1:" /etc/apk/repositories
|
||||
if grep -Eq "${pattern}" /etc/apk/repositories; then
|
||||
# Repo still commented out = Failure
|
||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${repo_str}"
|
||||
else
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${repo_str}"
|
||||
fi
|
||||
printf " %b %s..." "${INFO}" "${str}"
|
||||
if { ${PKG_INSTALL} -q -t "pihole-meta=${PIHOLE_META_VERSION_APK}" "${PIHOLE_META_DEPS_APK[@]}" &>/dev/null; }; then
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
else
|
||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_RED}"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
# we cannot install the dependency package
|
||||
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||
@@ -1416,6 +1506,15 @@ installCron() {
|
||||
# Randomize update checker time
|
||||
sed -i "s/59 17/$((1 + RANDOM % 58)) $((12 + RANDOM % 8))/" /etc/cron.d/pihole
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
|
||||
# Switch off of busybox cron on alpine
|
||||
if is_command openrc; then
|
||||
printf " %b Switching from busybox crond to cronie...\\n" "${INFO}"
|
||||
stop_service crond
|
||||
disable_service crond
|
||||
enable_service cronie
|
||||
restart_service cronie
|
||||
fi
|
||||
}
|
||||
|
||||
# Gravity is a very important script as it aggregates all of the domains into a single HOSTS formatted list,
|
||||
@@ -1465,7 +1564,7 @@ create_pihole_user() {
|
||||
# then create and add her to the pihole group
|
||||
local str="Creating user 'pihole'"
|
||||
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
||||
if useradd -r --no-user-group -g pihole -s /usr/sbin/nologin pihole; then
|
||||
if useradd -r --no-user-group -g pihole -s "$(command -v nologin)" pihole; then
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
else
|
||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||
@@ -1480,7 +1579,7 @@ create_pihole_user() {
|
||||
# create and add pihole user to the pihole group
|
||||
local str="Creating user 'pihole'"
|
||||
printf "%b %b %s..." "${OVER}" "${INFO}" "${str}"
|
||||
if useradd -r --no-user-group -g pihole -s /usr/sbin/nologin pihole; then
|
||||
if useradd -r --no-user-group -g pihole -s "$(command -v nologin)" pihole; then
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
else
|
||||
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||
@@ -1632,9 +1731,9 @@ check_download_exists() {
|
||||
status=$(curl --head --silent "https://ftl.pi-hole.net/${1}" | head -n 1)
|
||||
|
||||
# Check the status code
|
||||
if grep -q "200" <<<"$status"; then
|
||||
if grep -q "200" <<<"${status}"; then
|
||||
return 0
|
||||
elif grep -q "404" <<<"$status"; then
|
||||
elif grep -q "404" <<<"${status}"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -1667,7 +1766,7 @@ get_available_branches() {
|
||||
# Get reachable remote branches, but store STDERR as STDOUT variable
|
||||
output=$({ git ls-remote --heads --quiet | cut -d'/' -f3- -; } 2>&1)
|
||||
# echo status for calling function to capture
|
||||
echo "$output"
|
||||
echo "${output}"
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1700,9 +1799,9 @@ checkout_pull_branch() {
|
||||
oldbranch="$(git symbolic-ref HEAD)"
|
||||
|
||||
str="Switching to branch: '${branch}' from '${oldbranch}'"
|
||||
printf " %b %s" "${INFO}" "$str"
|
||||
printf " %b %s" "${INFO}" "${str}"
|
||||
git checkout "${branch}" --quiet || return 1
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "$str"
|
||||
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||
# Data in the repositories is public anyway so we can make it readable by everyone (+r to keep executable permission if already set by git)
|
||||
chmod -R a+rX "${directory}"
|
||||
|
||||
@@ -1717,6 +1816,12 @@ clone_or_reset_repos() {
|
||||
# If the user wants to repair/update,
|
||||
if [[ "${repair}" == true ]]; then
|
||||
printf " %b Resetting local repos\\n" "${INFO}"
|
||||
|
||||
# import getFTLConfigValue from utils.sh
|
||||
source "/opt/pihole/utils.sh"
|
||||
# Use the configured Web repo location on repair/update
|
||||
webInterfaceDir=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
|
||||
|
||||
# Reset the Core repo
|
||||
resetRepo ${PI_HOLE_LOCAL_REPO} ||
|
||||
{
|
||||
@@ -1790,8 +1895,12 @@ FTLinstall() {
|
||||
# Before stopping FTL, we download the macvendor database
|
||||
curl -sSL "https://ftl.pi-hole.net/macvendor.db" -o "${PI_HOLE_CONFIG_DIR}/macvendor.db" || true
|
||||
|
||||
# Stop pihole-FTL service if available
|
||||
stop_service pihole-FTL >/dev/null
|
||||
|
||||
# If the binary already exists in /usr/bin, then we need to stop the service
|
||||
# If the binary does not exist (fresh installs), then we can skip this step.
|
||||
if [[ -f /usr/bin/pihole-FTL ]]; then
|
||||
stop_service pihole-FTL >/dev/null
|
||||
fi
|
||||
|
||||
# Install the new version with the correct permissions
|
||||
install -T -m 0755 "${binary}" /usr/bin/pihole-FTL
|
||||
@@ -1905,7 +2014,7 @@ get_binary_name() {
|
||||
l_binary="pihole-FTL-riscv64"
|
||||
else
|
||||
# Something else - we try to use 32bit executable and warn the user
|
||||
if [[ ! "${machine}" == "i686" ]]; then
|
||||
if [[ "${machine}" != "i686" ]]; then
|
||||
printf "%b %b %s...\\n" "${OVER}" "${CROSS}" "${str}"
|
||||
printf " %b %bNot able to detect architecture (unknown: %s), trying x86 (32bit) executable%b\\n" "${INFO}" "${COL_RED}" "${machine}" "${COL_NC}"
|
||||
printf " %b Contact Pi-hole Support if you experience issues (e.g: FTL not running)\\n" "${INFO}"
|
||||
@@ -1939,14 +2048,14 @@ FTLcheckUpdate() {
|
||||
local remoteSha1
|
||||
local localSha1
|
||||
|
||||
if [[ ! "${ftlBranch}" == "master" ]]; then
|
||||
if [[ "${ftlBranch}" != "master" ]]; then
|
||||
# This is not the master branch
|
||||
local path
|
||||
path="${ftlBranch}/${binary}"
|
||||
|
||||
# Check whether or not the binary for this FTL branch actually exists. If not, then there is no update!
|
||||
local status
|
||||
if ! check_download_exists "$path"; then
|
||||
if ! check_download_exists "${path}"; then
|
||||
status=$?
|
||||
if [ "${status}" -eq 1 ]; then
|
||||
printf " %b Branch \"%s\" is not available.\\n" "${INFO}" "${ftlBranch}"
|
||||
@@ -2049,11 +2158,11 @@ make_temporary_log() {
|
||||
TEMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX)
|
||||
# Open handle 3 for templog
|
||||
# https://stackoverflow.com/questions/18460186/writing-outputs-to-log-file-and-console
|
||||
exec 3>"$TEMPLOG"
|
||||
exec 3>"${TEMPLOG}"
|
||||
# Delete templog, but allow for addressing via file handle
|
||||
# This lets us write to the log without having a temporary file on the drive, which
|
||||
# is meant to be a security measure so there is not a lingering file on the drive during the install process
|
||||
rm "$TEMPLOG"
|
||||
rm "${TEMPLOG}"
|
||||
}
|
||||
|
||||
copy_to_install_log() {
|
||||
@@ -2240,15 +2349,6 @@ main() {
|
||||
printf " %b %b--skipFTL set - skipping architecture check%b\\n" "${INFO}" "${COL_YELLOW}" "${COL_NC}"
|
||||
fi
|
||||
|
||||
if [[ "${fresh_install}" == false ]]; then
|
||||
# if it's running unattended,
|
||||
if [[ "${runUnattended}" == true ]]; then
|
||||
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
||||
# also disable debconf-apt-progress dialogs
|
||||
export DEBIAN_FRONTEND="noninteractive"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${fresh_install}" == true ]]; then
|
||||
# Display welcome dialogs
|
||||
welcomeDialogs
|
||||
@@ -2354,7 +2454,7 @@ main() {
|
||||
if [ -n "${PIHOLE_DNS_1}" ]; then
|
||||
local string="\"${PIHOLE_DNS_1}\""
|
||||
[ -n "${PIHOLE_DNS_2}" ] && string+=", \"${PIHOLE_DNS_2}\""
|
||||
setFTLConfigValue "dns.upstreams" "[ $string ]"
|
||||
setFTLConfigValue "dns.upstreams" "[ ${string} ]"
|
||||
fi
|
||||
|
||||
if [ -n "${QUERY_LOGGING}" ]; then
|
||||
@@ -2405,7 +2505,7 @@ main() {
|
||||
\\n\\nIPv4: ${IPV4_ADDRESS%/*}\
|
||||
\\nIPv6: ${IPV6_ADDRESS:-"Not Configured"}\
|
||||
\\nIf you have not done so already, the above IP should be set to static.\
|
||||
\\nView the web interface at http://pi.hole/admin:${WEBPORT} or http://${IPV4_ADDRESS%/*}:${WEBPORT}/admin\\n\\nYour Admin Webpage login password is ${pw}\
|
||||
\\nView the web interface at http://pi.hole:${WEBPORT}/admin or http://${IPV4_ADDRESS%/*}:${WEBPORT}/admin\\n\\nYour Admin Webpage login password is ${pw}\
|
||||
\\n
|
||||
\\n
|
||||
\\nTo allow your user to use all CLI functions without authentication,\
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
source "/opt/pihole/COL_TABLE"
|
||||
# shellcheck source="./advanced/Scripts/utils.sh"
|
||||
source "/opt/pihole/utils.sh"
|
||||
|
||||
ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
|
||||
readonly ADMIN_INTERFACE_DIR
|
||||
# getFTLConfigValue() from utils.sh
|
||||
|
||||
while true; do
|
||||
read -rp " ${QST} Are you sure you would like to remove ${COL_BOLD}Pi-hole${COL_NC}? [y/N] " answer
|
||||
@@ -29,125 +27,179 @@ str="Root user check"
|
||||
if [[ ${EUID} -eq 0 ]]; then
|
||||
echo -e " ${TICK} ${str}"
|
||||
else
|
||||
# Check if sudo is actually installed
|
||||
# If it isn't, exit because the uninstall can not complete
|
||||
if [ -x "$(command -v sudo)" ]; then
|
||||
export SUDO="sudo"
|
||||
else
|
||||
echo -e " ${CROSS} ${str}
|
||||
Script called with non-root privileges
|
||||
The Pi-hole requires elevated privileges to uninstall"
|
||||
exit 1
|
||||
fi
|
||||
echo -e " ${CROSS} ${str}
|
||||
Script called with non-root privileges
|
||||
The Pi-hole requires elevated privileges to uninstall"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||
# Get paths for admin interface, log files and database files,
|
||||
# to allow deletion where user has specified a non-default location
|
||||
ADMIN_INTERFACE_DIR=$(getFTLConfigValue "webserver.paths.webroot")$(getFTLConfigValue "webserver.paths.webhome")
|
||||
FTL_LOG=$(getFTLConfigValue "files.log.ftl")
|
||||
DNSMASQ_LOG=$(getFTLConfigValue "files.log.dnsmasq")
|
||||
WEBSERVER_LOG=$(getFTLConfigValue "files.log.webserver")
|
||||
PIHOLE_DB=$(getFTLConfigValue "files.database")
|
||||
GRAVITY_DB=$(getFTLConfigValue "files.gravity")
|
||||
MACVENDOR_DB=$(getFTLConfigValue "files.macvendor")
|
||||
|
||||
PI_HOLE_LOCAL_REPO="/etc/.pihole"
|
||||
# Setting SKIP_INSTALL="true" to source the installer functions without running them
|
||||
SKIP_INSTALL="true"
|
||||
# shellcheck source="./automated install/basic-install.sh"
|
||||
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||
|
||||
# package_manager_detect() sourced from basic-install.sh
|
||||
package_manager_detect
|
||||
|
||||
source "${PI_HOLE_LOCAL_REPO}/automated install/basic-install.sh"
|
||||
# Functions and Variables sources from basic-install:
|
||||
# package_manager_detect(), disable_service(), stop_service(),
|
||||
# restart service() and is_command()
|
||||
# PI_HOLE_CONFIG_DIR PI_HOLE_INSTALL_DIR PI_HOLE_LOCAL_REPO
|
||||
|
||||
removeMetaPackage() {
|
||||
# Purge Pi-hole meta package
|
||||
echo ""
|
||||
echo -ne " ${INFO} Removing Pi-hole meta package...";
|
||||
eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
||||
eval "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
||||
echo -e "${OVER} ${INFO} Removed Pi-hole meta package";
|
||||
|
||||
}
|
||||
|
||||
removePiholeFiles() {
|
||||
removeWebInterface() {
|
||||
# Remove the web interface of Pi-hole
|
||||
echo -ne " ${INFO} Removing Web Interface..."
|
||||
${SUDO} rm -rf "${ADMIN_INTERFACE_DIR}" &> /dev/null
|
||||
rm -rf "${ADMIN_INTERFACE_DIR:-/var/www/html/admin/}" &> /dev/null
|
||||
echo -e "${OVER} ${TICK} Removed Web Interface"
|
||||
}
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
# to guarantee no additional changes were made to /etc/crontab after
|
||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||
# preserved.
|
||||
if [[ -f /etc/crontab.orig ]]; then
|
||||
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
||||
${SUDO} mv /etc/crontab.orig /etc/crontab
|
||||
${SUDO} service cron restart
|
||||
echo -e " ${TICK} Restored the default system cron"
|
||||
fi
|
||||
removeFTL() {
|
||||
# Remove FTL and stop any running FTL service
|
||||
if is_command "pihole-FTL"; then
|
||||
# service stop & disable from basic_install.sh
|
||||
stop_service pihole-FTL
|
||||
disable_service pihole-FTL
|
||||
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
if [[ -f /etc/cron.d/pihole ]];then
|
||||
${SUDO} rm -f /etc/cron.d/pihole &> /dev/null
|
||||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||
fi
|
||||
|
||||
${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 /opt/pihole/ &> /dev/null
|
||||
${SUDO} rm -f /usr/local/bin/pihole &> /dev/null
|
||||
${SUDO} rm -f /etc/bash_completion.d/pihole &> /dev/null
|
||||
${SUDO} rm -f /etc/sudoers.d/pihole &> /dev/null
|
||||
echo -e " ${TICK} Removed config files"
|
||||
|
||||
# Restore Resolved
|
||||
if [[ -e /etc/systemd/resolved.conf.orig ]] || [[ -e /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf ]]; then
|
||||
${SUDO} cp -p /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf &> /dev/null || true
|
||||
${SUDO} rm -f /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
fi
|
||||
|
||||
# Remove FTL
|
||||
if command -v pihole-FTL &> /dev/null; then
|
||||
echo -ne " ${INFO} Removing 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
|
||||
rm -f /etc/systemd/system/pihole-FTL.service &> /dev/null
|
||||
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
|
||||
case $answer in
|
||||
[yY]*)
|
||||
echo -ne " ${INFO} Removing /etc/systemd/system/pihole-FTL.service.d..."
|
||||
${SUDO} rm -R /etc/systemd/system/pihole-FTL.service.d
|
||||
rm -R /etc/systemd/system/pihole-FTL.service.d &> /dev/null
|
||||
echo -e "${OVER} ${INFO} Removed /etc/systemd/system/pihole-FTL.service.d"
|
||||
;;
|
||||
*) echo -e " ${INFO} Leaving /etc/systemd/system/pihole-FTL.service.d in place.";;
|
||||
esac
|
||||
fi
|
||||
${SUDO} rm -f /etc/init.d/pihole-FTL
|
||||
${SUDO} rm -f /usr/bin/pihole-FTL
|
||||
rm -f /etc/init.d/pihole-FTL &> /dev/null
|
||||
rm -f /usr/bin/pihole-FTL &> /dev/null
|
||||
echo -e "${OVER} ${TICK} Removed pihole-FTL"
|
||||
|
||||
# Force systemd reload after service files are removed
|
||||
if is_command "systemctl"; then
|
||||
echo -ne " ${INFO} Restarting systemd..."
|
||||
systemctl daemon-reload
|
||||
echo -e "${OVER} ${TICK} Restarted systemd..."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
removeCronFiles() {
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
# to guarantee no additional changes were made to /etc/crontab after
|
||||
# the installation of pihole, /etc/crontab.pihole should be permanently
|
||||
# preserved.
|
||||
if [[ -f /etc/crontab.orig ]]; then
|
||||
mv /etc/crontab /etc/crontab.pihole
|
||||
mv /etc/crontab.orig /etc/crontab
|
||||
restart_service cron
|
||||
echo -e " ${TICK} Restored the default system cron"
|
||||
echo -e " ${INFO} A backup of the most recent crontab is saved at /etc/crontab.pihole"
|
||||
fi
|
||||
|
||||
# If the pihole manpage exists, then delete and rebuild man-db
|
||||
# Attempt to preserve backwards compatibility with older versions
|
||||
if [[ -f /etc/cron.d/pihole ]];then
|
||||
rm -f /etc/cron.d/pihole &> /dev/null
|
||||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||
fi
|
||||
}
|
||||
|
||||
removePiholeFiles() {
|
||||
# Remove databases (including user specified non-default paths)
|
||||
rm -f "${PIHOLE_DB:-/etc/pihole/pihole-FTL.db}" &> /dev/null
|
||||
rm -f "${GRAVITY_DB:-/etc/pihole/gravity.db}" &> /dev/null
|
||||
rm -f "${MACVENDOR_DB:-/etc/pihole/macvendor.db}" &> /dev/null
|
||||
|
||||
# Remove pihole config, repo and local files
|
||||
rm -rf "${PI_HOLE_CONFIG_DIR:-/etc/pihole}" &> /dev/null
|
||||
rm -rf "${PI_HOLE_LOCAL_REPO:-/etc/.pihole}" &> /dev/null
|
||||
rm -rf "${PI_HOLE_INSTALL_DIR:-/opt/pihole}" &> /dev/null
|
||||
|
||||
# Remove log files (including user specified non-default paths)
|
||||
# and rotated logs
|
||||
# Explicitly escape spaces, in case of trailing space in path before wildcard
|
||||
rm -f "$(printf '%q' "${FTL_LOG:-/var/log/pihole/FTL.log}")*" &> /dev/null
|
||||
rm -f "$(printf '%q' "${DNSMASQ_LOG:-/var/log/pihole/pihole.log}")*" &> /dev/null
|
||||
rm -f "$(printf '%q' "${WEBSERVER_LOG:-/var/log/pihole/webserver.log}")*" &> /dev/null
|
||||
|
||||
# remove any remnant log-files from old versions
|
||||
rm -rf /var/log/*pihole* &> /dev/null
|
||||
|
||||
# remove log directory
|
||||
rm -rf /var/log/pihole &> /dev/null
|
||||
|
||||
# remove the pihole command
|
||||
rm -f /usr/local/bin/pihole &> /dev/null
|
||||
|
||||
# remove Pi-hole's bash completion
|
||||
rm -f /etc/bash_completion.d/pihole &> /dev/null
|
||||
rm -f /etc/bash_completion.d/pihole-FTL &> /dev/null
|
||||
|
||||
# Remove pihole from sudoers for compatibility with old versions
|
||||
rm -f /etc/sudoers.d/pihole &> /dev/null
|
||||
|
||||
echo -e " ${TICK} Removed config files"
|
||||
}
|
||||
|
||||
removeManPage() {
|
||||
# If the pihole manpage exists, then delete
|
||||
if [[ -f /usr/local/share/man/man8/pihole.8 ]]; then
|
||||
${SUDO} rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
|
||||
${SUDO} mandb -q &>/dev/null
|
||||
rm -f /usr/local/share/man/man8/pihole.8 /usr/local/share/man/man8/pihole-FTL.8 /usr/local/share/man/man5/pihole-FTL.conf.5
|
||||
# Rebuild man-db if present
|
||||
if is_command "mandb"; then
|
||||
mandb -q &>/dev/null
|
||||
fi
|
||||
echo -e " ${TICK} Removed pihole man page"
|
||||
fi
|
||||
}
|
||||
|
||||
removeUser() {
|
||||
# If the pihole user exists, then remove
|
||||
if id "pihole" &> /dev/null; then
|
||||
if ${SUDO} userdel -r pihole 2> /dev/null; then
|
||||
if userdel -r pihole 2> /dev/null; then
|
||||
echo -e " ${TICK} Removed 'pihole' user"
|
||||
else
|
||||
echo -e " ${CROSS} Unable to remove 'pihole' user"
|
||||
fi
|
||||
fi
|
||||
|
||||
# If the pihole group exists, then remove
|
||||
if getent group "pihole" &> /dev/null; then
|
||||
if ${SUDO} groupdel pihole 2> /dev/null; then
|
||||
if groupdel pihole 2> /dev/null; then
|
||||
echo -e " ${TICK} Removed 'pihole' group"
|
||||
else
|
||||
echo -e " ${CROSS} Unable to remove 'pihole' group"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
restoreResolved() {
|
||||
# Restore Resolved from saved configuration, if present
|
||||
if [[ -e /etc/systemd/resolved.conf.orig ]] || [[ -e /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf ]]; then
|
||||
cp -p /etc/systemd/resolved.conf.orig /etc/systemd/resolved.conf &> /dev/null || true
|
||||
rm -f /etc/systemd/resolved.conf.d/90-pi-hole-disable-stub-listener.conf &> /dev/null
|
||||
systemctl reload-or-restart systemd-resolved
|
||||
fi
|
||||
}
|
||||
|
||||
completionMessage() {
|
||||
echo -e "\\n We're sorry to see you go, but thanks for checking out Pi-hole!
|
||||
If you need help, reach out to us on GitHub, Discourse, Reddit or Twitter
|
||||
Reinstall at any time: ${COL_BOLD}curl -sSL https://install.pi-hole.net | bash${COL_NC}
|
||||
@@ -158,5 +210,17 @@ removePiholeFiles() {
|
||||
}
|
||||
|
||||
######### SCRIPT ###########
|
||||
# The ordering here allows clean uninstallation with nothing
|
||||
# removed before anything that depends upon it.
|
||||
# eg removeFTL relies on scripts removed by removePiholeFiles
|
||||
# removeUser relies on commands removed by removeMetaPackage
|
||||
package_manager_detect
|
||||
removeWebInterface
|
||||
removeCronFiles
|
||||
restoreResolved
|
||||
removeManPage
|
||||
removeFTL
|
||||
removeUser
|
||||
removeMetaPackage
|
||||
removePiholeFiles
|
||||
completionMessage
|
||||
|
||||
Reference in New Issue
Block a user