mirror of
https://github.com/pi-hole/pi-hole
synced 2025-01-07 06:30:55 +00:00
Merge branch 'development' into tweak/gravity_backup
This commit is contained in:
commit
fab1ca3a40
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@ -65,7 +65,6 @@ jobs:
|
|||||||
debian_12,
|
debian_12,
|
||||||
ubuntu_20,
|
ubuntu_20,
|
||||||
ubuntu_22,
|
ubuntu_22,
|
||||||
ubuntu_23,
|
|
||||||
ubuntu_24,
|
ubuntu_24,
|
||||||
centos_9,
|
centos_9,
|
||||||
fedora_40,
|
fedora_40,
|
||||||
|
@ -165,15 +165,17 @@ GetFTLData() {
|
|||||||
# get the data from querying the API as well as the http status code
|
# get the data from querying the API as well as the http status code
|
||||||
response=$(curl -skS -w "%{http_code}" -X GET "${API_URL}$1" -H "Accept: application/json" -H "sid: ${SID}" )
|
response=$(curl -skS -w "%{http_code}" -X GET "${API_URL}$1" -H "Accept: application/json" -H "sid: ${SID}" )
|
||||||
|
|
||||||
# status are the last 3 characters
|
|
||||||
status="${response#"${response%???}"}"
|
|
||||||
# data is everything from response without the last 3 characters
|
|
||||||
data="${response%???}"
|
|
||||||
|
|
||||||
if [ "${2}" = "raw" ]; then
|
if [ "${2}" = "raw" ]; then
|
||||||
# return the raw response
|
# return the raw response
|
||||||
echo "${response}"
|
echo "${response}"
|
||||||
else
|
else
|
||||||
|
|
||||||
|
# status are the last 3 characters
|
||||||
|
# not using ${response#"${response%???}"}" here because it's extremely slow on big responses
|
||||||
|
status=$(printf "%s" "${response}" | tail -c 3)
|
||||||
|
# data is everything from response without the last 3 characters
|
||||||
|
data="${response%???}"
|
||||||
|
|
||||||
# return only the data
|
# return only the data
|
||||||
if [ "${status}" = 200 ]; then
|
if [ "${status}" = 200 ]; then
|
||||||
# response OK
|
# response OK
|
||||||
@ -264,7 +266,8 @@ apiFunc() {
|
|||||||
response=$(GetFTLData "$1" raw)
|
response=$(GetFTLData "$1" raw)
|
||||||
|
|
||||||
# status are the last 3 characters
|
# status are the last 3 characters
|
||||||
status="${response#"${response%???}"}"
|
# not using ${response#"${response%???}"}" here because it's extremely slow on big responses
|
||||||
|
status=$(printf "%s" "${response}" | tail -c 3)
|
||||||
# data is everything from response without the last 3 characters
|
# data is everything from response without the last 3 characters
|
||||||
data="${response%???}"
|
data="${response%???}"
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ flushARP(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Stop FTL to prevent database access
|
# Stop FTL to prevent database access
|
||||||
if ! output=$(pihole-FTL service stop 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
|
||||||
@ -64,7 +64,7 @@ flushARP(){
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Start FTL again
|
# Start FTL again
|
||||||
if ! output=$(pihole-FTL service restart 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
|
||||||
|
@ -109,7 +109,8 @@ main() {
|
|||||||
|
|
||||||
# Install packages used by this installation script (necessary if users have removed e.g. git from their systems)
|
# Install packages used by this installation script (necessary if users have removed e.g. git from their systems)
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
install_dependent_packages "${INSTALLER_DEPS[@]}"
|
build_dependency_package
|
||||||
|
install_dependent_packages
|
||||||
|
|
||||||
# This is unlikely
|
# This is unlikely
|
||||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#
|
#
|
||||||
# Example usage:
|
# Example usage:
|
||||||
# addOrEditKeyValPair "/etc/pihole/setupVars.conf" "BLOCKING_ENABLED" "true"
|
# addOrEditKeyValPair "/etc/pihole/setupVars.conf" "BLOCKING_ENABLED" "true"
|
||||||
# TODO: We miight not actually need this function in v6
|
|
||||||
#######################
|
#######################
|
||||||
addOrEditKeyValPair() {
|
addOrEditKeyValPair() {
|
||||||
local file="${1}"
|
local file="${1}"
|
||||||
@ -44,43 +43,6 @@ addOrEditKeyValPair() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################
|
|
||||||
# Takes two arguments: file, and key.
|
|
||||||
# Adds a key to target file
|
|
||||||
#
|
|
||||||
# Example usage:
|
|
||||||
# addKey "/etc/dnsmasq.d/01-pihole.conf" "log-queries"
|
|
||||||
#######################
|
|
||||||
addKey(){
|
|
||||||
local file="${1}"
|
|
||||||
local key="${2}"
|
|
||||||
|
|
||||||
# touch file to prevent grep error if file does not exist yet
|
|
||||||
touch "${file}"
|
|
||||||
|
|
||||||
# Match key against entire line, using both anchors. We assume
|
|
||||||
# that the file's keys never have bounding whitespace. Anchors
|
|
||||||
# are necessary to ensure the key is considered absent when it
|
|
||||||
# is a substring of another key present in the file.
|
|
||||||
if ! grep -q "^${key}$" "${file}"; then
|
|
||||||
# Key does not exist, add it.
|
|
||||||
echo "${key}" >> "${file}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Takes two arguments: file, and key.
|
|
||||||
# Deletes a key or key/value pair from target file
|
|
||||||
#
|
|
||||||
# Example usage:
|
|
||||||
# removeKey "/etc/pihole/setupVars.conf" "PIHOLE_DNS_1"
|
|
||||||
#######################
|
|
||||||
removeKey() {
|
|
||||||
local file="${1}"
|
|
||||||
local key="${2}"
|
|
||||||
sed -i "/^${key}/d" "${file}"
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# returns FTL's PID based on the content of the pihole-FTL.pid file
|
# returns FTL's PID based on the content of the pihole-FTL.pid file
|
||||||
#
|
#
|
||||||
|
@ -25,6 +25,9 @@ set -e
|
|||||||
# When using "su" an incomplete PATH could be passed: https://github.com/pi-hole/pi-hole/issues/3209
|
# When using "su" an incomplete PATH could be passed: https://github.com/pi-hole/pi-hole/issues/3209
|
||||||
export PATH+=':/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
export PATH+=':/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
|
||||||
|
|
||||||
|
# Trap any errors, then exit
|
||||||
|
trap abort INT QUIT TERM
|
||||||
|
|
||||||
######## VARIABLES #########
|
######## VARIABLES #########
|
||||||
# For better maintainability, we store as much information that can change in variables
|
# For better maintainability, we store as much information that can change in variables
|
||||||
# This allows us to make a change in one place that can propagate to all instances of the variable
|
# This allows us to make a change in one place that can propagate to all instances of the variable
|
||||||
@ -88,7 +91,7 @@ IPV4_ADDRESS=${IPV4_ADDRESS}
|
|||||||
IPV6_ADDRESS=${IPV6_ADDRESS}
|
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||||
# Give settings their default values. These may be changed by prompts later in the script.
|
# Give settings their default values. These may be changed by prompts later in the script.
|
||||||
QUERY_LOGGING=
|
QUERY_LOGGING=
|
||||||
WEBPORT=8080
|
WEBPORT=
|
||||||
PRIVACY_LEVEL=
|
PRIVACY_LEVEL=
|
||||||
|
|
||||||
# Where old configs go to if a v6 migration is performed
|
# Where old configs go to if a v6 migration is performed
|
||||||
@ -102,6 +105,40 @@ fi
|
|||||||
r=20
|
r=20
|
||||||
c=70
|
c=70
|
||||||
|
|
||||||
|
# Content of Pi-hole's meta package control file on APT based systems
|
||||||
|
PIHOLE_META_PACKAGE_CONTROL_APT=$(
|
||||||
|
cat <<EOM
|
||||||
|
Package: pihole-meta
|
||||||
|
Version: 0.1
|
||||||
|
Maintainer: Pi-hole team <adblock@pi-hole.net>
|
||||||
|
Architecture: all
|
||||||
|
Description: Pi-hole dependency meta package
|
||||||
|
Depends: grep,dnsutils,binutils,git,iproute2,dialog,ca-certificates,cron,curl,iputils-ping,psmisc,sudo,unzip,libcap2-bin,dns-root-data,libcap2,netcat-openbsd,procps,jq,lshw,bash-completion
|
||||||
|
EOM
|
||||||
|
)
|
||||||
|
|
||||||
|
# Content of Pi-hole's meta package control file on RPM based systems
|
||||||
|
PIHOLE_META_PACKAGE_CONTROL_RPM=$(
|
||||||
|
cat <<EOM
|
||||||
|
Name: pihole-meta
|
||||||
|
Version: 0.1
|
||||||
|
Release: 1
|
||||||
|
License: EUPL
|
||||||
|
BuildArch: noarch
|
||||||
|
Summary: Pi-hole dependency meta package
|
||||||
|
Requires: grep,curl,psmisc,sudo, unzip,jq,git,dialog,ca-certificates, bind-utils, iproute, procps-ng, chkconfig, binutils, cronie, findutils, libcap, nmap-ncat, lshw, bash-completion
|
||||||
|
%description
|
||||||
|
Pi-hole dependency meta package
|
||||||
|
%prep
|
||||||
|
%build
|
||||||
|
%files
|
||||||
|
%install
|
||||||
|
%changelog
|
||||||
|
* Sun Sep 29 2024 Pi-hole Team - 0.1
|
||||||
|
- First version being packaged
|
||||||
|
EOM
|
||||||
|
)
|
||||||
|
|
||||||
######## Undocumented Flags. Shhh ########
|
######## Undocumented Flags. Shhh ########
|
||||||
# These are undocumented flags; some of which we can use when repairing an installation
|
# These are undocumented flags; some of which we can use when repairing an installation
|
||||||
# The runUnattended flag is one example of this
|
# The runUnattended flag is one example of this
|
||||||
@ -160,6 +197,19 @@ show_ascii_berry() {
|
|||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abort() {
|
||||||
|
|
||||||
|
# remove any leftover build directory that may exist
|
||||||
|
rm -rf /tmp/pihole-meta_*
|
||||||
|
|
||||||
|
echo -e "\\n\\n ${COL_LIGHT_RED}Installation was interrupted${COL_NC}\\n"
|
||||||
|
echo -e "Pi-hole's dependencies might be already installed. If you want to remove them you can try to\\n"
|
||||||
|
echo -e "a) run 'pihole uninstall' \\n"
|
||||||
|
echo -e "b) Remove the meta-package 'pihole-meta' manually \\n"
|
||||||
|
echo -e "E.g. sudo apt-get remove pihole-meta && apt-get autoremove \\n"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
is_command() {
|
is_command() {
|
||||||
# Checks to see if the given command (passed as a string argument) exists on the system.
|
# Checks to see if the given command (passed as a string argument) exists on the system.
|
||||||
# The function returns 0 (success) if the command exists, and 1 if it doesn't.
|
# The function returns 0 (success) if the command exists, and 1 if it doesn't.
|
||||||
@ -362,10 +412,6 @@ test_dpkg_lock() {
|
|||||||
|
|
||||||
# Compatibility
|
# Compatibility
|
||||||
package_manager_detect() {
|
package_manager_detect() {
|
||||||
# pull common packages for both distributions out into a common variable
|
|
||||||
OS_CHECK_COMMON_DEPS=(grep)
|
|
||||||
PIHOLE_COMMON_DEPS=(curl psmisc sudo unzip jq);
|
|
||||||
INSTALLER_COMMON_DEPS=(git dialog ca-certificates)
|
|
||||||
|
|
||||||
# First check to see if apt-get is installed.
|
# First check to see if apt-get is installed.
|
||||||
if is_command apt-get; then
|
if is_command apt-get; then
|
||||||
@ -375,17 +421,13 @@ package_manager_detect() {
|
|||||||
# A variable to store the command used to update the package cache
|
# A variable to store the command used to update the package cache
|
||||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||||
# The command we will use to actually install packages
|
# The command we will use to actually install packages
|
||||||
PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install)
|
PKG_INSTALL="${PKG_MANAGER} -qq --no-install-recommends install"
|
||||||
# grep -c will return 1 if there are no matches. This is an acceptable condition, so we OR TRUE to prevent set -e exiting the script.
|
# grep -c will return 1 if there are no matches. This is an acceptable condition, so we OR TRUE to prevent set -e exiting the script.
|
||||||
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
|
||||||
|
# The command we will use to remove packages (used in the uninstaller)
|
||||||
|
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
||||||
# Update package cache
|
# Update package cache
|
||||||
update_package_cache || exit 1
|
update_package_cache || exit 1
|
||||||
# Packages required to perform the os_check and FTL binary detection
|
|
||||||
OS_CHECK_DEPS=(dnsutils binutils)
|
|
||||||
# Packages required to run this install script
|
|
||||||
INSTALLER_DEPS=(iproute2)
|
|
||||||
# Packages required to run Pi-hole
|
|
||||||
PIHOLE_DEPS=(cron iputils-ping libcap2-bin dns-root-data libcap2 netcat-openbsd procps lshw bash-completion)
|
|
||||||
|
|
||||||
# If apt-get is not found, check for rpm.
|
# If apt-get is not found, check for rpm.
|
||||||
elif is_command rpm; then
|
elif is_command rpm; then
|
||||||
@ -397,13 +439,11 @@ package_manager_detect() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# These variable names match the ones for apt-get. See above for an explanation of what they are for.
|
# These variable names match the ones for apt-get. See above for an explanation of what they are for.
|
||||||
PKG_INSTALL=("${PKG_MANAGER}" install -y)
|
PKG_INSTALL="${PKG_MANAGER} install -y"
|
||||||
# CentOS package manager returns 100 when there are packages to update so we need to || true to prevent the script from exiting.
|
# CentOS package manager returns 100 when there are packages to update so we need to || true to prevent the script from exiting.
|
||||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||||
OS_CHECK_DEPS=(bind-utils)
|
# The command we will use to remove packages (used in the uninstaller)
|
||||||
INSTALLER_DEPS=(iproute newt procps-ng chkconfig binutils)
|
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
||||||
PIHOLE_DEPS=(cronie findutils libcap nmap-ncat lshw bash-completion)
|
|
||||||
|
|
||||||
# If neither apt-get or yum/dnf package managers were found
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
else
|
else
|
||||||
# we cannot install required packages
|
# we cannot install required packages
|
||||||
@ -413,6 +453,100 @@ package_manager_detect() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build_dependency_package(){
|
||||||
|
# This function will build a package that contains all the dependencies needed for Pi-hole
|
||||||
|
|
||||||
|
# remove any leftover build directory that may exist
|
||||||
|
rm -rf /tmp/pihole-meta_*
|
||||||
|
|
||||||
|
# Create a fresh build directory with random name
|
||||||
|
local tempdir
|
||||||
|
tempdir="$(mktemp --directory /tmp/pihole-meta_XXXXX)"
|
||||||
|
chmod 0755 "${tempdir}"
|
||||||
|
|
||||||
|
if is_command apt-get; then
|
||||||
|
# move into the tmp directory
|
||||||
|
pushd /tmp &>/dev/null || return 1
|
||||||
|
|
||||||
|
# remove leftover package if it exists from previous runs
|
||||||
|
rm -f /tmp/pihole-meta.deb
|
||||||
|
|
||||||
|
# Prepare directory structure and control file
|
||||||
|
mkdir -p "${tempdir}"/DEBIAN
|
||||||
|
chmod 0755 "${tempdir}"/DEBIAN
|
||||||
|
touch "${tempdir}"/DEBIAN/control
|
||||||
|
|
||||||
|
# Write the control file
|
||||||
|
echo "${PIHOLE_META_PACKAGE_CONTROL_APT}" > "${tempdir}"/DEBIAN/control
|
||||||
|
|
||||||
|
# Build the package
|
||||||
|
local str="Building dependency package pihole-meta.deb"
|
||||||
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
|
|
||||||
|
if dpkg-deb --build --root-owner-group "${tempdir}" pihole-meta.deb &>/dev/null; then
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
else
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
|
printf "%b Error: Building pihole-meta.deb failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Move back into the directory the user started in
|
||||||
|
popd &> /dev/null || return 1
|
||||||
|
|
||||||
|
elif is_command rpm; then
|
||||||
|
# move into the tmp directory
|
||||||
|
pushd /tmp &>/dev/null || return 1
|
||||||
|
|
||||||
|
# remove leftover package if it exists from previous runs
|
||||||
|
rm -f /tmp/pihole-meta.rpm
|
||||||
|
|
||||||
|
# Prepare directory structure and spec file
|
||||||
|
mkdir -p "${tempdir}"/SPECS
|
||||||
|
touch "${tempdir}"/SPECS/pihole-meta.spec
|
||||||
|
echo "${PIHOLE_META_PACKAGE_CONTROL_RPM}" > "${tempdir}"/SPECS/pihole-meta.spec
|
||||||
|
|
||||||
|
# check if we need to install the build dependencies
|
||||||
|
if ! is_command rpmbuild; then
|
||||||
|
local REMOVE_RPM_BUILD=true
|
||||||
|
eval "${PKG_INSTALL}" "rpm-build"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the package
|
||||||
|
local str="Building dependency package pihole-meta.rpm"
|
||||||
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
|
|
||||||
|
if rpmbuild -bb "${tempdir}"/SPECS/pihole-meta.spec --define "_topdir ${tempdir}" &>/dev/null; then
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
else
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
|
printf "%b Error: Building pihole-meta.rpm failed. %b\\n" "${COL_LIGHT_RED}" "${COL_NC}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Move the package to the /tmp directory
|
||||||
|
mv "${tempdir}"/RPMS/noarch/pihole-meta*.rpm /tmp/pihole-meta.rpm
|
||||||
|
|
||||||
|
# Remove the build dependencies when we've installed them
|
||||||
|
if [ -n "${REMOVE_RPM_BUILD}" ]; then
|
||||||
|
eval "${PKG_REMOVE}" "rpm-build"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Move back into the directory the user started in
|
||||||
|
popd &> /dev/null || return 1
|
||||||
|
|
||||||
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
|
else
|
||||||
|
# we cannot build required packages
|
||||||
|
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||||
|
# so exit the installer
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove the build directory
|
||||||
|
rm -rf "${tempdir}"
|
||||||
|
}
|
||||||
|
|
||||||
# A function for checking if a directory is a git repository
|
# A function for checking if a directory is a git repository
|
||||||
is_repo() {
|
is_repo() {
|
||||||
# Use a named, local variable instead of the vague $1, which is the first argument passed to this function
|
# Use a named, local variable instead of the vague $1, which is the first argument passed to this function
|
||||||
@ -1390,61 +1524,49 @@ notify_package_updates_available() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_dependent_packages() {
|
install_dependent_packages() {
|
||||||
|
# Install meta dependency package
|
||||||
|
local str="Installing Pi-hole dependency package"
|
||||||
|
printf " %b %s..." "${INFO}" "${str}"
|
||||||
|
|
||||||
# Install packages passed in via argument array
|
# Install Debian/Ubuntu packages
|
||||||
# No spinner - conflicts with set -e
|
|
||||||
declare -a installArray
|
|
||||||
|
|
||||||
# Debian based package install - debconf will download the entire package list
|
|
||||||
# so we just create an array of packages not currently installed to cut down on the
|
|
||||||
# amount of download traffic.
|
|
||||||
# NOTE: We may be able to use this installArray in the future to create a list of package that were
|
|
||||||
# installed by us, and remove only the installed packages, and not the entire list.
|
|
||||||
if is_command apt-get; then
|
if is_command apt-get; then
|
||||||
# For each package, check if it's already installed (and if so, don't add it to the installArray)
|
if [ -f /tmp/pihole-meta.deb ]; then
|
||||||
for i in "$@"; do
|
if eval "${PKG_INSTALL}" "/tmp/pihole-meta.deb" &>/dev/null; then
|
||||||
printf " %b Checking for %s..." "${INFO}" "${i}"
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
if dpkg-query -W -f='${Status}' "${i}" 2>/dev/null | grep "ok installed" &>/dev/null; then
|
rm /tmp/pihole-meta.deb
|
||||||
printf "%b %b Checking for %s\\n" "${OVER}" "${TICK}" "${i}"
|
|
||||||
else
|
else
|
||||||
printf "%b %b Checking for %s (will be installed)\\n" "${OVER}" "${INFO}" "${i}"
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
installArray+=("${i}")
|
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
else
|
||||||
# If there's anything to install, install everything in the list.
|
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
if [[ "${#installArray[@]}" -gt 0 ]]; then
|
return 1
|
||||||
test_dpkg_lock
|
|
||||||
# Running apt-get install with minimal output can cause some issues with
|
|
||||||
# requiring user input (e.g password for phpmyadmin see #218)
|
|
||||||
printf " %b Processing %s install(s) for: %s, please wait...\\n" "${INFO}" "${PKG_MANAGER}" "${installArray[*]}"
|
|
||||||
printf '%*s\n' "${c}" '' | tr " " -
|
|
||||||
"${PKG_INSTALL[@]}" "${installArray[@]}"
|
|
||||||
printf '%*s\n' "${c}" '' | tr " " -
|
|
||||||
return
|
|
||||||
fi
|
fi
|
||||||
printf "\\n"
|
# Install Fedora/CentOS packages
|
||||||
return 0
|
elif is_command rpm; then
|
||||||
|
if [ -f /tmp/pihole-meta.rpm ]; then
|
||||||
|
if eval "${PKG_INSTALL}" "/tmp/pihole-meta.rpm" &>/dev/null; then
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
|
||||||
|
rm /tmp/pihole-meta.rpm
|
||||||
|
else
|
||||||
|
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
|
||||||
|
printf " %b Error: Unable to install Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
printf " %b Error: Unable to find Pi-hole dependency package.\\n" "${COL_LIGHT_RED}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
|
else
|
||||||
|
# we cannot install the dependency package
|
||||||
|
printf " %b No supported package manager found\\n" "${CROSS}"
|
||||||
|
# so exit the installer
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Fedora/CentOS packages
|
|
||||||
for i in "$@"; do
|
|
||||||
# For each package, check if it's already installed (and if so, don't add it to the installArray)
|
|
||||||
printf " %b Checking for %s..." "${INFO}" "${i}"
|
|
||||||
if rpm -q "${i}" &>/dev/null; then
|
|
||||||
printf "%b %b Checking for %s\\n" "${OVER}" "${TICK}" "${i}"
|
|
||||||
else
|
|
||||||
printf "%b %b Checking for %s (will be installed)\\n" "${OVER}" "${INFO}" "${i}"
|
|
||||||
installArray+=("${i}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
# If there's anything to install, install everything in the list.
|
|
||||||
if [[ "${#installArray[@]}" -gt 0 ]]; then
|
|
||||||
printf " %b Processing %s install(s) for: %s, please wait...\\n" "${INFO}" "${PKG_MANAGER}" "${installArray[*]}"
|
|
||||||
printf '%*s\n' "${c}" '' | tr " " -
|
|
||||||
"${PKG_INSTALL[@]}" "${installArray[@]}"
|
|
||||||
printf '%*s\n' "${c}" '' | tr " " -
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -1606,15 +1728,6 @@ installPihole() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# /opt/pihole/utils.sh should be installed by installScripts now, so we can use it
|
|
||||||
if [ -f "${PI_HOLE_INSTALL_DIR}/utils.sh" ]; then
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source "${PI_HOLE_INSTALL_DIR}/utils.sh"
|
|
||||||
else
|
|
||||||
printf " %b Failure: /opt/pihole/utils.sh does not exist .\\n" "${CROSS}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
remove_old_dnsmasq_ftl_configs
|
remove_old_dnsmasq_ftl_configs
|
||||||
remove_old_pihole_lighttpd_configs
|
remove_old_pihole_lighttpd_configs
|
||||||
|
|
||||||
@ -2187,6 +2300,39 @@ copy_to_install_log() {
|
|||||||
chown pihole:pihole "${installLogLoc}"
|
chown pihole:pihole "${installLogLoc}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableLighttpd() {
|
||||||
|
local response
|
||||||
|
# Detect if the terminal is interactive
|
||||||
|
if [[ -t 0 ]]; then
|
||||||
|
# The terminal is interactive
|
||||||
|
dialog --no-shadow --keep-tite \
|
||||||
|
--title "Pi-hole v6.0 no longer uses lighttpd" \
|
||||||
|
--yesno "\\n\\nPi-hole v6.0 has its own embedded web server so lighttpd is no longer needed *unless* you have custom configurations.\\n\\nIn this case, you can opt-out of disabling lighttpd and pihole-FTL will try to bind to an alternative port such as 8080.\\n\\nDo you want to disable lighttpd (recommended)?" "${r}" "${c}" && response=0 || response="$?"
|
||||||
|
else
|
||||||
|
# The terminal is non-interactive, assume yes. Lighttpd will be stopped
|
||||||
|
# but keeps being installed and can easily be re-enabled by the user
|
||||||
|
response=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the user does not want to disable lighttpd, return early
|
||||||
|
if [[ "${response}" -ne 0 ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Lighttpd is not needed anymore, so disable it
|
||||||
|
# We keep all the configuration files in place, so the user can re-enable it
|
||||||
|
# if needed
|
||||||
|
|
||||||
|
# Check if lighttpd is installed
|
||||||
|
if is_command lighttpd; then
|
||||||
|
# Stop the lighttpd service
|
||||||
|
stop_service lighttpd
|
||||||
|
|
||||||
|
# Disable the lighttpd service
|
||||||
|
disable_service lighttpd
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
migrate_dnsmasq_configs() {
|
migrate_dnsmasq_configs() {
|
||||||
# Previously, Pi-hole created a number of files in /etc/dnsmasq.d
|
# Previously, Pi-hole created a number of files in /etc/dnsmasq.d
|
||||||
# During migration, their content is copied into the new single source of
|
# During migration, their content is copied into the new single source of
|
||||||
@ -2215,6 +2361,17 @@ migrate_dnsmasq_configs() {
|
|||||||
mv /etc/dnsmasq.d/06-rfc6761.conf "${V6_CONF_MIGRATION_DIR}/" 2>/dev/null || true
|
mv /etc/dnsmasq.d/06-rfc6761.conf "${V6_CONF_MIGRATION_DIR}/" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check for availability of either the "service" or "systemctl" commands
|
||||||
|
check_service_command() {
|
||||||
|
# Check for the availability of the "service" command
|
||||||
|
if ! is_command service && ! is_command systemctl; then
|
||||||
|
# If neither the "service" nor the "systemctl" command is available, inform the user
|
||||||
|
printf " %b Neither the service nor the systemctl commands are available\\n" "${CROSS}"
|
||||||
|
printf " on this machine. This Pi-hole installer cannot continue.\\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
######## FIRST CHECK ########
|
######## FIRST CHECK ########
|
||||||
# Must be root to install
|
# Must be root to install
|
||||||
@ -2263,15 +2420,20 @@ main() {
|
|||||||
# Check if SELinux is Enforcing and exit before doing anything else
|
# Check if SELinux is Enforcing and exit before doing anything else
|
||||||
checkSelinux
|
checkSelinux
|
||||||
|
|
||||||
|
# Check for availability of either the "service" or "systemctl" commands
|
||||||
|
check_service_command
|
||||||
|
|
||||||
# Check for supported package managers so that we may install dependencies
|
# Check for supported package managers so that we may install dependencies
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
|
|
||||||
# Notify user of package availability
|
# Notify user of package availability
|
||||||
notify_package_updates_available
|
notify_package_updates_available
|
||||||
|
|
||||||
# Install packages necessary to perform os_check
|
# Build dependency package
|
||||||
printf " %b Checking for / installing required dependencies for OS Check...\\n" "${INFO}"
|
build_dependency_package
|
||||||
install_dependent_packages "${OS_CHECK_COMMON_DEPS[@]}" "${OS_CHECK_DEPS[@]}"
|
|
||||||
|
# Install Pi-hole dependencies
|
||||||
|
install_dependent_packages
|
||||||
|
|
||||||
# Check that the installed OS is officially supported - display warning if not
|
# Check that the installed OS is officially supported - display warning if not
|
||||||
os_check
|
os_check
|
||||||
@ -2286,12 +2448,8 @@ main() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install packages used by this installation script
|
# in case of an update (can be a v5 -> v6 or v6 -> v6 update)
|
||||||
printf " %b Checking for / installing required dependencies for this install script...\\n" "${INFO}"
|
if [[ -f "${PI_HOLE_V6_CONFIG}" ]] || [[ -f "/etc/pihole/setupVars.conf" ]]; then
|
||||||
install_dependent_packages "${INSTALLER_COMMON_DEPS[@]}" "${INSTALLER_DEPS[@]}"
|
|
||||||
|
|
||||||
# in case of an update
|
|
||||||
if [[ -f "${PI_HOLE_V6_CONFIG}" ]]; then
|
|
||||||
# if it's running unattended,
|
# if it's running unattended,
|
||||||
if [[ "${runUnattended}" == true ]]; then
|
if [[ "${runUnattended}" == true ]]; then
|
||||||
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
printf " %b Performing unattended setup, no dialogs will be displayed\\n" "${INFO}"
|
||||||
@ -2331,13 +2489,6 @@ main() {
|
|||||||
# Download or update the scripts by updating the appropriate git repos
|
# Download or update the scripts by updating the appropriate git repos
|
||||||
clone_or_update_repos
|
clone_or_update_repos
|
||||||
|
|
||||||
# Install the Core dependencies
|
|
||||||
local dep_install_list=("${PIHOLE_COMMON_DEPS[@]}" "${PIHOLE_DEPS[@]}")
|
|
||||||
|
|
||||||
# Install packages used by the actual software
|
|
||||||
printf " %b Checking for / installing required dependencies for Pi-hole software...\\n" "${INFO}"
|
|
||||||
install_dependent_packages "${dep_install_list[@]}"
|
|
||||||
unset dep_install_list
|
|
||||||
|
|
||||||
# Create the pihole user
|
# Create the pihole user
|
||||||
create_pihole_user
|
create_pihole_user
|
||||||
@ -2355,6 +2506,15 @@ main() {
|
|||||||
# Install and log everything to a file
|
# Install and log everything to a file
|
||||||
installPihole | tee -a /proc/$$/fd/3
|
installPihole | tee -a /proc/$$/fd/3
|
||||||
|
|
||||||
|
# /opt/pihole/utils.sh should be installed by installScripts now, so we can use it
|
||||||
|
if [ -f "${PI_HOLE_INSTALL_DIR}/utils.sh" ]; then
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "${PI_HOLE_INSTALL_DIR}/utils.sh"
|
||||||
|
else
|
||||||
|
printf " %b Failure: /opt/pihole/utils.sh does not exist .\\n" "${CROSS}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy the temp log file into final log location for storage
|
# Copy the temp log file into final log location for storage
|
||||||
copy_to_install_log
|
copy_to_install_log
|
||||||
|
|
||||||
@ -2364,7 +2524,7 @@ main() {
|
|||||||
if [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then
|
if [[ $(pihole-FTL --config webserver.api.pwhash) == '""' ]]; then
|
||||||
# generate a random password
|
# generate a random password
|
||||||
pw=$(tr -dc _A-Z-a-z-0-9 </dev/urandom | head -c 8)
|
pw=$(tr -dc _A-Z-a-z-0-9 </dev/urandom | head -c 8)
|
||||||
pihole -a -p "${pw}"
|
pihole setpassword "${pw}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Migrate existing install to v6.0
|
# Migrate existing install to v6.0
|
||||||
@ -2376,6 +2536,9 @@ main() {
|
|||||||
# but before starting or resttarting the ftl service
|
# but before starting or resttarting the ftl service
|
||||||
disable_resolved_stublistener
|
disable_resolved_stublistener
|
||||||
|
|
||||||
|
# Disable lighttpd server
|
||||||
|
disableLighttpd
|
||||||
|
|
||||||
# Check if gravity database needs to be upgraded. If so, do it without rebuilding
|
# Check if gravity database needs to be upgraded. If so, do it without rebuilding
|
||||||
# gravity altogether. This may be a very long running task needlessly blocking
|
# gravity altogether. This may be a very long running task needlessly blocking
|
||||||
# the update process.
|
# the update process.
|
||||||
@ -2408,18 +2571,20 @@ main() {
|
|||||||
# Update local and remote versions via updatechecker
|
# Update local and remote versions via updatechecker
|
||||||
/opt/pihole/updatecheck.sh
|
/opt/pihole/updatecheck.sh
|
||||||
|
|
||||||
if [[ "${useUpdateVars}" == false ]]; then
|
|
||||||
displayFinalMessage "${pw}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If there is a password
|
# If there is a password
|
||||||
if ((${#pw} > 0)); then
|
if ((${#pw} > 0)); then
|
||||||
# display the password
|
# display the password
|
||||||
printf " %b Web Interface password: %b%s%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${pw}" "${COL_NC}"
|
printf " %b Web Interface password: %b%s%b\\n" "${INFO}" "${COL_LIGHT_GREEN}" "${pw}" "${COL_NC}"
|
||||||
printf " %b This can be changed using 'pihole -a -p'\\n\\n" "${INFO}"
|
printf " %b This can be changed using 'pihole setpassword'\\n\\n" "${INFO}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${useUpdateVars}" == false ]]; then
|
if [[ "${useUpdateVars}" == false ]]; then
|
||||||
|
# Get the Web interface port, return only the first port and strip all non-numeric characters
|
||||||
|
WEBPORT=$(getFTLConfigValue webserver.port|cut -d, -f1 | tr -cd '0-9')
|
||||||
|
|
||||||
|
# Display the completion dialog
|
||||||
|
displayFinalMessage "${pw}"
|
||||||
|
|
||||||
# If the Web interface was installed,
|
# If the Web interface was installed,
|
||||||
printf " %b View the web interface at http://pi.hole:${WEBPORT}/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}:${WEBPORT}"
|
printf " %b View the web interface at http://pi.hole:${WEBPORT}/admin or http://%s/admin\\n\\n" "${INFO}" "${IPV4_ADDRESS%/*}:${WEBPORT}"
|
||||||
|
|
||||||
|
@ -38,68 +38,25 @@ fi
|
|||||||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||||
SKIP_INSTALL="true"
|
SKIP_INSTALL="true"
|
||||||
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||||
# setupVars set in basic-install.sh
|
|
||||||
source "${setupVars}"
|
|
||||||
|
|
||||||
# package_manager_detect() sourced from basic-install.sh
|
# package_manager_detect() sourced from basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
|
|
||||||
# Uninstall packages used by the Pi-hole
|
|
||||||
DEPS=("${INSTALLER_COMMON_DEPS[@]}" "${PIHOLE_COMMON_DEPS[@]}" "${OS_CHECK_COMMON_DEPS[@]}" "${INSTALLER_DEPS[@]}" "${PIHOLE_DEPS[@]}" "${OS_CHECK_DEPS[@]}")
|
|
||||||
|
|
||||||
# Compatibility
|
removeMetaPackage() {
|
||||||
if [ -x "$(command -v apt-get)" ]; then
|
# Purge Pi-hole meta package
|
||||||
# Debian Family
|
|
||||||
PKG_REMOVE=("${PKG_MANAGER}" -y remove --purge)
|
|
||||||
package_check() {
|
|
||||||
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
|
||||||
}
|
|
||||||
elif [ -x "$(command -v rpm)" ]; then
|
|
||||||
# Fedora Family
|
|
||||||
PKG_REMOVE=("${PKG_MANAGER}" remove -y)
|
|
||||||
package_check() {
|
|
||||||
rpm -qa | grep "^$1-" > /dev/null
|
|
||||||
}
|
|
||||||
else
|
|
||||||
echo -e " ${CROSS} OS distribution not supported"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
removeAndPurge() {
|
|
||||||
# Purge dependencies
|
|
||||||
echo ""
|
echo ""
|
||||||
for i in "${DEPS[@]}"; do
|
echo -ne " ${INFO} Removing Pi-hole meta package...";
|
||||||
if package_check "${i}" > /dev/null; then
|
eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
||||||
while true; do
|
echo -e "${OVER} ${INFO} Removed Pi-hole meta package";
|
||||||
read -rp " ${QST} Do you wish to remove ${COL_WHITE}${i}${COL_NC} from your system? [Y/N] " answer
|
|
||||||
case ${answer} in
|
|
||||||
[Yy]* )
|
|
||||||
echo -ne " ${INFO} Removing ${i}...";
|
|
||||||
${SUDO} "${PKG_REMOVE[@]}" "${i}" &> /dev/null;
|
|
||||||
echo -e "${OVER} ${INFO} Removed ${i}";
|
|
||||||
break;;
|
|
||||||
[Nn]* ) echo -e " ${INFO} Skipped ${i}"; break;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo -e " ${INFO} Package ${i} not installed"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Remove dnsmasq config files
|
|
||||||
${SUDO} rm -f /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/*-pihole*.conf &> /dev/null
|
|
||||||
echo -e " ${TICK} Removing dnsmasq config files"
|
|
||||||
|
|
||||||
# Call removeNoPurge to remove Pi-hole specific files
|
|
||||||
removeNoPurge
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeNoPurge() {
|
removePiholeFiles() {
|
||||||
# Only web directories/files that are created by Pi-hole should be removed
|
# Only web directories/files that are created by Pi-hole should be removed
|
||||||
echo -ne " ${INFO} Removing Web Interface..."
|
echo -ne " ${INFO} Removing Web Interface..."
|
||||||
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
||||||
${SUDO} rm -rf /var/www/html/pihole &> /dev/null
|
|
||||||
${SUDO} rm -f /var/www/html/index.lighttpd.orig &> /dev/null
|
|
||||||
|
|
||||||
# If the web directory is empty after removing these files, then the parent html directory can be removed.
|
# If the web directory is empty after removing these files, then the parent html directory can be removed.
|
||||||
if [ -d "/var/www/html" ]; then
|
if [ -d "/var/www/html" ]; then
|
||||||
@ -126,45 +83,6 @@ removeNoPurge() {
|
|||||||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if package_check lighttpd > /dev/null; then
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
|
||||||
if [[ -f /etc/lighttpd/lighttpd.conf.orig ]]; then
|
|
||||||
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f /etc/lighttpd/external.conf ]]; then
|
|
||||||
${SUDO} rm /etc/lighttpd/external.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fedora-based
|
|
||||||
if [[ -f /etc/lighttpd/conf.d/pihole-admin.conf ]]; then
|
|
||||||
${SUDO} rm /etc/lighttpd/conf.d/pihole-admin.conf
|
|
||||||
conf=/etc/lighttpd/lighttpd.conf
|
|
||||||
tconf=/tmp/lighttpd.conf.$$
|
|
||||||
if awk '!/^include "\/etc\/lighttpd\/conf\.d\/pihole-admin\.conf"$/{print}' \
|
|
||||||
$conf > $tconf && mv $tconf $conf; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
rm $tconf
|
|
||||||
fi
|
|
||||||
${SUDO} chown root:root $conf
|
|
||||||
${SUDO} chmod 644 $conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Debian-based
|
|
||||||
if [[ -f /etc/lighttpd/conf-available/pihole-admin.conf ]]; then
|
|
||||||
if is_command lighty-disable-mod ; then
|
|
||||||
${SUDO} lighty-disable-mod pihole-admin > /dev/null || true
|
|
||||||
fi
|
|
||||||
${SUDO} rm /etc/lighttpd/conf-available/15-pihole-admin.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e " ${TICK} Removed lighttpd configs"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${SUDO} rm -f /etc/dnsmasq.d/adList.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 -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 /var/log/pihole/*pihole* &> /dev/null
|
||||||
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
||||||
@ -234,23 +152,11 @@ removeNoPurge() {
|
|||||||
If you need help, reach out to us on GitHub, Discourse, Reddit or Twitter
|
If you need help, reach out to us on GitHub, Discourse, Reddit or Twitter
|
||||||
Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC}
|
Reinstall at any time: ${COL_WHITE}curl -sSL https://install.pi-hole.net | bash${COL_NC}
|
||||||
|
|
||||||
${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity
|
${COL_LIGHT_RED}Please reset the DNS on your router/clients to restore internet connectivity${COL_NC}
|
||||||
|
${INFO} Pi-hole's meta package has been removed, use the 'autoremove' function from your package manager to remove unused dependencies${COL_NC}
|
||||||
${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}"
|
${COL_LIGHT_GREEN}Uninstallation Complete! ${COL_NC}"
|
||||||
}
|
}
|
||||||
|
|
||||||
######### SCRIPT ###########
|
######### SCRIPT ###########
|
||||||
echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed"
|
removeMetaPackage
|
||||||
while true; do
|
removePiholeFiles
|
||||||
echo -e " ${INFO} ${COL_YELLOW}The following dependencies may have been added by the Pi-hole install:"
|
|
||||||
echo -n " "
|
|
||||||
for i in "${DEPS[@]}"; do
|
|
||||||
echo -n "${i} "
|
|
||||||
done
|
|
||||||
echo "${COL_NC}"
|
|
||||||
read -rp " ${QST} Do you wish to go through each dependency for removal? (Choosing No will leave all dependencies installed) [Y/n] " answer
|
|
||||||
case ${answer} in
|
|
||||||
[Yy]* ) removeAndPurge; break;;
|
|
||||||
[Nn]* ) removeNoPurge; break;;
|
|
||||||
* ) removeAndPurge; break;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
@ -5,19 +5,15 @@ Pi-hole : A black-hole for internet advertisements
|
|||||||
.br
|
.br
|
||||||
.SH "SYNOPSIS"
|
.SH "SYNOPSIS"
|
||||||
|
|
||||||
\fBpihole\fR (\fB-w\fR|\fB-b\fR|\fB--wild\fR|\fB--regex\fR) [options] domain(s)
|
\fBpihole\fR (\fB-allow\fR|\fB-deny\fR) [options] domain(s)
|
||||||
.br
|
.br
|
||||||
\fBpihole -a\fR \fB-p\fR password
|
\fBpihole\fR (\fB--allow-regex\fR|\fB--regex\fR) [options] domain(s)
|
||||||
.br
|
.br
|
||||||
\fBpihole -a\fR (\fB-c|-f|-k\fR)
|
\fBpihole\fR (\fB--allow-wild\fR|\fB--wild\fR) [options] domain(s)
|
||||||
.br
|
.br
|
||||||
\fBpihole -a -i\fR interface
|
\fBpihole setpassword\fR password
|
||||||
.br
|
.br
|
||||||
\fBpihole -a -l\fR privacylevel
|
\fBpihole\fR \fB-d\fR [-a] [-c]
|
||||||
.br
|
|
||||||
\fBpihole -c\fR [-j|-r|-e]
|
|
||||||
.br
|
|
||||||
\fBpihole\fR \fB-d\fR [-a]
|
|
||||||
.br
|
.br
|
||||||
\fBpihole -f
|
\fBpihole -f
|
||||||
.br
|
.br
|
||||||
@ -25,7 +21,7 @@ pihole -r
|
|||||||
.br
|
.br
|
||||||
\fBpihole\fR \fB-t\fR [arg]
|
\fBpihole\fR \fB-t\fR [arg]
|
||||||
.br
|
.br
|
||||||
pihole -g\fR
|
\fBpihole -g\fR
|
||||||
.br
|
.br
|
||||||
\fBpihole\fR -\fBq\fR [options]
|
\fBpihole\fR -\fBq\fR [options]
|
||||||
.br
|
.br
|
||||||
@ -33,20 +29,22 @@ pihole -g\fR
|
|||||||
.br
|
.br
|
||||||
\fBpihole -up \fR[--check-only]
|
\fBpihole -up \fR[--check-only]
|
||||||
.br
|
.br
|
||||||
\fBpihole -v\fR [-p|-a|-f] [-c|-l|-hash]
|
\fBpihole -v\fR
|
||||||
.br
|
.br
|
||||||
\fBpihole uninstall
|
\fBpihole uninstall\fR
|
||||||
.br
|
.br
|
||||||
pihole status
|
\fBpihole status\fR
|
||||||
.br
|
.br
|
||||||
pihole reloaddns\fR
|
\fBpihole reloaddns\fR
|
||||||
.br
|
.br
|
||||||
pihole reloadlists\fR
|
\fBpihole reloadlists\fR
|
||||||
.br
|
.br
|
||||||
\fBpihole\fR (\fBenable\fR|\fBdisable\fR [time])
|
\fBpihole\fR (\fBenable\fR|\fBdisable\fR [time])
|
||||||
.br
|
.br
|
||||||
\fBpihole\fR \fBcheckout\fR repo [branch]
|
\fBpihole\fR \fBcheckout\fR repo [branch]
|
||||||
.br
|
.br
|
||||||
|
\fBpihole\fR \api\fR endpoint
|
||||||
|
.br
|
||||||
\fBpihole\fR \fBhelp\fR
|
\fBpihole\fR \fBhelp\fR
|
||||||
.br
|
.br
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
@ -99,6 +97,7 @@ Available commands and options:
|
|||||||
.br
|
.br
|
||||||
|
|
||||||
-a Enable automated debugging
|
-a Enable automated debugging
|
||||||
|
-c Include a Pi-hole database integrity check
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-f, flush\fR
|
\fB-f, flush\fR
|
||||||
@ -120,25 +119,6 @@ Available commands and options:
|
|||||||
(regular expressions are supported)
|
(regular expressions are supported)
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-a, admin\fR [options]
|
|
||||||
.br
|
|
||||||
|
|
||||||
(Admin options):
|
|
||||||
.br
|
|
||||||
-p, password Set Web Interface password
|
|
||||||
.br
|
|
||||||
-c, celsius Set Celsius as preferred temperature unit
|
|
||||||
.br
|
|
||||||
-f, fahrenheit Set Fahrenheit as preferred temperature unit
|
|
||||||
.br
|
|
||||||
-k, kelvin Set Kelvin as preferred temperature unit
|
|
||||||
.br
|
|
||||||
-i, interface Specify dnsmasq's interface listening behavior
|
|
||||||
.br
|
|
||||||
-l, privacylevel <level> Set privacy level
|
|
||||||
(0 = lowest, 3 = highest)
|
|
||||||
.br
|
|
||||||
|
|
||||||
\fB-g, updateGravity\fR
|
\fB-g, updateGravity\fR
|
||||||
.br
|
.br
|
||||||
Update the list of ad-serving domains
|
Update the list of ad-serving domains
|
||||||
@ -151,11 +131,9 @@ Available commands and options:
|
|||||||
|
|
||||||
(Query options):
|
(Query options):
|
||||||
.br
|
.br
|
||||||
-adlist Print the name of the block list URL
|
-partial Search the adlists for partially matching domains
|
||||||
.br
|
.br
|
||||||
-exact Search the block lists for exact domain matches
|
-all Return all query matches within a adlists
|
||||||
.br
|
|
||||||
-all Return all query matches within a block list
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-h, --help, help\fR
|
\fB-h, --help, help\fR
|
||||||
@ -186,29 +164,14 @@ Available commands and options:
|
|||||||
--check-only Exit script before update is performed.
|
--check-only Exit script before update is performed.
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fB-v, version\fR [repo] [options]
|
\fB-v, version\fR
|
||||||
.br
|
.br
|
||||||
Show installed versions of Pi-hole, Web Interface & FTL
|
Show installed versions of Pi-hole, Web Interface & FTL
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
\fBsetpassword\fR
|
||||||
.br
|
.br
|
||||||
(repo options):
|
Set Web Interface password
|
||||||
.br
|
|
||||||
-p, --pihole Only retrieve info regarding Pi-hole repository
|
|
||||||
.br
|
|
||||||
-a, --admin Only retrieve info regarding web
|
|
||||||
repository
|
|
||||||
.br
|
|
||||||
-f, --ftl Only retrieve info regarding FTL repository
|
|
||||||
.br
|
|
||||||
(version options):
|
|
||||||
.br
|
|
||||||
-c, --current Return the current version
|
|
||||||
.br
|
|
||||||
-l, --latest Return the latest version
|
|
||||||
.br
|
|
||||||
--hash Return the GitHub hash from your local
|
|
||||||
repositories
|
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBuninstall\fR
|
\fBuninstall\fR
|
||||||
@ -221,14 +184,14 @@ Available commands and options:
|
|||||||
Display the running status of Pi-hole subsystems
|
Display the running status of Pi-hole subsystems
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBenable\fR
|
\fBenable\fR [time]
|
||||||
.br
|
.br
|
||||||
Enable Pi-hole subsystems
|
Enable Pi-hole blocking, optionally for a set duration
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBdisable\fR [time]
|
\fBdisable\fR [time]
|
||||||
.br
|
.br
|
||||||
Disable Pi-hole subsystems, optionally for a set duration
|
Disable Pi-hole blocking, optionally for a set duration
|
||||||
.br
|
.br
|
||||||
|
|
||||||
(time options):
|
(time options):
|
||||||
@ -270,6 +233,11 @@ Available commands and options:
|
|||||||
.br
|
.br
|
||||||
branchname Update subsystems to the specified branchname
|
branchname Update subsystems to the specified branchname
|
||||||
.br
|
.br
|
||||||
|
|
||||||
|
\fBapi\fR endpoint
|
||||||
|
.br
|
||||||
|
Query the Pi-hole API at <endpoint>
|
||||||
|
.br
|
||||||
.SH "EXAMPLE"
|
.SH "EXAMPLE"
|
||||||
|
|
||||||
Some usage examples
|
Some usage examples
|
||||||
@ -283,7 +251,7 @@ Allow-/denylist manipulation
|
|||||||
Allow "iloveads.example.com"
|
Allow "iloveads.example.com"
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBpihole deny not noads.example.com\fR
|
\fBpihole deny remove noads.example.com\fR
|
||||||
.br
|
.br
|
||||||
Removes "noads.example.com" from denylist
|
Removes "noads.example.com" from denylist
|
||||||
.br
|
.br
|
||||||
@ -303,7 +271,7 @@ Allow-/denylist manipulation
|
|||||||
Changing the Web Interface password
|
Changing the Web Interface password
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBpihole -a -p ExamplePassword\fR
|
\fBpihole setpassword ExamplePassword\fR
|
||||||
.br
|
.br
|
||||||
Change the password to "ExamplePassword"
|
Change the password to "ExamplePassword"
|
||||||
.br
|
.br
|
||||||
@ -319,9 +287,9 @@ Updating lists from internet sources
|
|||||||
Displaying version information
|
Displaying version information
|
||||||
.br
|
.br
|
||||||
|
|
||||||
\fBpihole -v -a -c\fR
|
\fBpihole -v\fR
|
||||||
.br
|
.br
|
||||||
Display the current version of web
|
Display the current version of Pi-hole
|
||||||
.br
|
.br
|
||||||
|
|
||||||
Temporarily disabling Pi-hole
|
Temporarily disabling Pi-hole
|
||||||
@ -350,10 +318,11 @@ Switching Pi-hole subsystem branches
|
|||||||
Flush information stored in Pi-hole's network tables
|
Flush information stored in Pi-hole's network tables
|
||||||
.br
|
.br
|
||||||
|
|
||||||
.SH "SEE ALSO"
|
\fBpihole api stats/summary\fR
|
||||||
|
|
||||||
\fBlighttpd\fR(8), \fBpihole-FTL\fR(8)
|
|
||||||
.br
|
.br
|
||||||
|
Queries FTL for the stats/summary endpoint
|
||||||
|
.br
|
||||||
|
|
||||||
.SH "COLOPHON"
|
.SH "COLOPHON"
|
||||||
|
|
||||||
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net.
|
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net.
|
||||||
|
1
pihole
1
pihole
@ -501,6 +501,7 @@ Options:
|
|||||||
uninstall Uninstall Pi-hole from your system
|
uninstall Uninstall Pi-hole from your system
|
||||||
status Display the running status of Pi-hole subsystems
|
status Display the running status of Pi-hole subsystems
|
||||||
enable Enable Pi-hole subsystems
|
enable Enable Pi-hole subsystems
|
||||||
|
Add '-h' for more info on enable usage
|
||||||
disable Disable Pi-hole subsystems
|
disable Disable Pi-hole subsystems
|
||||||
Add '-h' for more info on disable usage
|
Add '-h' for more info on disable usage
|
||||||
reloaddns Update the lists and flush the cache without restarting the DNS server
|
reloaddns Update the lists and flush the cache without restarting the DNS server
|
||||||
|
@ -8,7 +8,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -5,7 +5,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -5,7 +5,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -6,7 +6,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -6,7 +6,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -5,7 +5,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
RUN true && \
|
RUN true && \
|
||||||
|
@ -5,7 +5,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
FROM buildpack-deps:lunar-scm
|
|
||||||
|
|
||||||
ENV GITDIR=/etc/.pihole
|
|
||||||
ENV SCRIPTDIR=/opt/pihole
|
|
||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
|
||||||
ADD . $GITDIR
|
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN true && \
|
|
||||||
chmod +x $SCRIPTDIR/*
|
|
||||||
|
|
||||||
ENV SKIP_INSTALL=true
|
|
||||||
ENV OS_CHECK_DOMAIN_NAME=dev-supportedos.pi-hole.net
|
|
||||||
|
|
||||||
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
|
@ -5,7 +5,7 @@ ENV SCRIPTDIR=/opt/pihole
|
|||||||
|
|
||||||
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
ADD . $GITDIR
|
ADD . $GITDIR
|
||||||
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $GITDIR/advanced/Scripts/COL_TABLE $SCRIPTDIR/
|
||||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
@ -5,9 +5,8 @@ import subprocess
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
IMAGE = "pytest_pihole:test_container"
|
IMAGE = "pytest_pihole:test_container"
|
||||||
|
tick_box = "[✓]"
|
||||||
tick_box = "[\x1b[1;32m\u2713\x1b[0m]"
|
cross_box = "[✗]"
|
||||||
cross_box = "[\x1b[1;31m\u2717\x1b[0m]"
|
|
||||||
info_box = "[i]"
|
info_box = "[i]"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
pyyaml == 6.0.2
|
pyyaml == 6.0.2
|
||||||
pytest == 8.3.3
|
pytest == 8.3.4
|
||||||
pytest-xdist == 3.6.1
|
pytest-xdist == 3.6.1
|
||||||
pytest-testinfra == 10.1.1
|
pytest-testinfra == 10.1.1
|
||||||
tox == 4.23.2
|
tox == 4.23.2
|
||||||
|
@ -12,7 +12,7 @@ from .conftest import (
|
|||||||
run_script,
|
run_script,
|
||||||
)
|
)
|
||||||
|
|
||||||
FTL_BRANCH = "development-v6"
|
FTL_BRANCH = "development"
|
||||||
|
|
||||||
|
|
||||||
def test_supported_package_manager(host):
|
def test_supported_package_manager(host):
|
||||||
@ -480,8 +480,8 @@ def test_os_check_fails(host):
|
|||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
install_dependent_packages ${OS_CHECK_DEPS[@]}
|
build_dependency_package
|
||||||
install_dependent_packages ${INSTALLER_DEPS[@]}
|
install_dependent_packages
|
||||||
cat <<EOT > /etc/os-release
|
cat <<EOT > /etc/os-release
|
||||||
ID=UnsupportedOS
|
ID=UnsupportedOS
|
||||||
VERSION_ID="2"
|
VERSION_ID="2"
|
||||||
@ -504,8 +504,8 @@ def test_os_check_passes(host):
|
|||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
install_dependent_packages ${OS_CHECK_DEPS[@]}
|
build_dependency_package
|
||||||
install_dependent_packages ${INSTALLER_DEPS[@]}
|
install_dependent_packages
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
detectOS = host.run(
|
detectOS = host.run(
|
||||||
@ -518,21 +518,6 @@ def test_os_check_passes(host):
|
|||||||
assert expected_stdout in detectOS.stdout
|
assert expected_stdout in detectOS.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_package_manager_has_installer_deps(host):
|
|
||||||
"""Confirms OS is able to install the required packages for the installer"""
|
|
||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
|
||||||
output = host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/basic-install.sh
|
|
||||||
package_manager_detect
|
|
||||||
install_dependent_packages ${INSTALLER_DEPS[@]}
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
assert "No package" not in output.stdout
|
|
||||||
assert output.rc == 0
|
|
||||||
|
|
||||||
|
|
||||||
def test_package_manager_has_pihole_deps(host):
|
def test_package_manager_has_pihole_deps(host):
|
||||||
"""Confirms OS is able to install the required packages for Pi-hole"""
|
"""Confirms OS is able to install the required packages for Pi-hole"""
|
||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
mock_command("dialog", {"*": ("", "0")}, host)
|
||||||
@ -540,7 +525,8 @@ def test_package_manager_has_pihole_deps(host):
|
|||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
install_dependent_packages ${PIHOLE_DEPS[@]}
|
build_dependency_package
|
||||||
|
install_dependent_packages
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -548,16 +534,23 @@ def test_package_manager_has_pihole_deps(host):
|
|||||||
assert output.rc == 0
|
assert output.rc == 0
|
||||||
|
|
||||||
|
|
||||||
def test_package_manager_has_web_deps(host):
|
def test_meta_package_uninstall(host):
|
||||||
"""Confirms OS is able to install the required packages for web"""
|
"""Confirms OS is able to install and uninstall the Pi-hole meta package"""
|
||||||
mock_command("dialog", {"*": ("", "0")}, host)
|
mock_command("dialog", {"*": ("", "0")}, host)
|
||||||
output = host.run(
|
install = host.run(
|
||||||
"""
|
"""
|
||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
package_manager_detect
|
package_manager_detect
|
||||||
install_dependent_packages ${PIHOLE_WEB_DEPS[@]}
|
build_dependency_package
|
||||||
|
install_dependent_packages
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
assert install.rc == 0
|
||||||
|
|
||||||
assert "No package" not in output.stdout
|
uninstall = host.run(
|
||||||
assert output.rc == 0
|
"""
|
||||||
|
source /opt/pihole/uninstall.sh
|
||||||
|
removeMetaPackage
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
assert uninstall.rc == 0
|
||||||
|
@ -18,70 +18,6 @@ def test_key_val_replacement_works(host):
|
|||||||
assert expected_stdout == output.stdout
|
assert expected_stdout == output.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_key_addition_works(host):
|
|
||||||
"""Confirms addKey adds a key (no value) to a file without duplicating it"""
|
|
||||||
host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/utils.sh
|
|
||||||
addKey "./testoutput" "KEY_ONE"
|
|
||||||
addKey "./testoutput" "KEY_ONE"
|
|
||||||
addKey "./testoutput" "KEY_TWO"
|
|
||||||
addKey "./testoutput" "KEY_TWO"
|
|
||||||
addKey "./testoutput" "KEY_THREE"
|
|
||||||
addKey "./testoutput" "KEY_THREE"
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
output = host.run(
|
|
||||||
"""
|
|
||||||
cat ./testoutput
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "KEY_ONE\nKEY_TWO\nKEY_THREE\n"
|
|
||||||
assert expected_stdout == output.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_key_addition_substr(host):
|
|
||||||
"""Confirms addKey adds substring keys (no value) to a file"""
|
|
||||||
host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/utils.sh
|
|
||||||
addKey "./testoutput" "KEY_ONE"
|
|
||||||
addKey "./testoutput" "KEY_O"
|
|
||||||
addKey "./testoutput" "KEY_TWO"
|
|
||||||
addKey "./testoutput" "Y_TWO"
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
output = host.run(
|
|
||||||
"""
|
|
||||||
cat ./testoutput
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "KEY_ONE\nKEY_O\nKEY_TWO\nY_TWO\n"
|
|
||||||
assert expected_stdout == output.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_key_removal_works(host):
|
|
||||||
"""Confirms removeKey removes a key or key/value pair"""
|
|
||||||
host.run(
|
|
||||||
"""
|
|
||||||
source /opt/pihole/utils.sh
|
|
||||||
addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1"
|
|
||||||
addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2"
|
|
||||||
addOrEditKeyValPair "./testoutput" "KEY_THREE" "value3"
|
|
||||||
addKey "./testoutput" "KEY_FOUR"
|
|
||||||
removeKey "./testoutput" "KEY_TWO"
|
|
||||||
removeKey "./testoutput" "KEY_FOUR"
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
output = host.run(
|
|
||||||
"""
|
|
||||||
cat ./testoutput
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
expected_stdout = "KEY_ONE=value1\nKEY_THREE=value3\n"
|
|
||||||
assert expected_stdout == output.stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_getFTLPID_default(host):
|
def test_getFTLPID_default(host):
|
||||||
"""Confirms getFTLPID returns the default value if FTL is not running"""
|
"""Confirms getFTLPID returns the default value if FTL is not running"""
|
||||||
output = host.run(
|
output = host.run(
|
||||||
@ -105,7 +41,7 @@ def test_setFTLConfigValue_getFTLConfigValue(host):
|
|||||||
source /opt/pihole/basic-install.sh
|
source /opt/pihole/basic-install.sh
|
||||||
create_pihole_user
|
create_pihole_user
|
||||||
funcOutput=$(get_binary_name)
|
funcOutput=$(get_binary_name)
|
||||||
echo "development-v6" > /etc/pihole/ftlbranch
|
echo "development" > /etc/pihole/ftlbranch
|
||||||
binary="pihole-FTL${funcOutput##*pihole-FTL}"
|
binary="pihole-FTL${funcOutput##*pihole-FTL}"
|
||||||
theRest="${funcOutput%pihole-FTL*}"
|
theRest="${funcOutput%pihole-FTL*}"
|
||||||
FTLdetect "${binary}" "${theRest}"
|
FTLdetect "${binary}" "${theRest}"
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
[tox]
|
|
||||||
envlist = py3
|
|
||||||
|
|
||||||
[testenv:py3]
|
|
||||||
allowlist_externals = docker
|
|
||||||
deps = -rrequirements.txt
|
|
||||||
setenv =
|
|
||||||
COLUMNS=120
|
|
||||||
commands = docker buildx build --load --progress plain -f _ubuntu_23.Dockerfile -t pytest_pihole:test_container ../
|
|
||||||
pytest {posargs:-vv -n auto} ./test_any_automated_install.py ./test_any_utils.py
|
|
Loading…
Reference in New Issue
Block a user