mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 14:20:18 +00:00
Install dependencies by creating a meta package on-the-fly (#5785)
This commit is contained in:
commit
4dbf9a0bbb
15 changed files with 201 additions and 231 deletions
|
@ -109,7 +109,8 @@ main() {
|
|||
|
||||
# Install packages used by this installation script (necessary if users have removed e.g. git from their systems)
|
||||
package_manager_detect
|
||||
install_dependent_packages "${INSTALLER_DEPS[@]}"
|
||||
build_dependency_package
|
||||
install_dependent_packages
|
||||
|
||||
# This is unlikely
|
||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||
|
|
|
@ -25,6 +25,9 @@ set -e
|
|||
# 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'
|
||||
|
||||
# Trap any errors, then exit
|
||||
trap abort INT QUIT TERM
|
||||
|
||||
######## 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
|
||||
|
@ -102,6 +105,40 @@ fi
|
|||
r=20
|
||||
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 ########
|
||||
# These are undocumented flags; some of which we can use when repairing an installation
|
||||
# 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() {
|
||||
# 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.
|
||||
|
@ -362,10 +412,6 @@ test_dpkg_lock() {
|
|||
|
||||
# Compatibility
|
||||
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.
|
||||
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
|
||||
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
|
||||
# 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.
|
||||
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 || 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.
|
||||
elif is_command rpm; then
|
||||
|
@ -397,13 +439,11 @@ package_manager_detect() {
|
|||
fi
|
||||
|
||||
# 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.
|
||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||
OS_CHECK_DEPS=(bind-utils)
|
||||
INSTALLER_DEPS=(iproute newt procps-ng chkconfig binutils)
|
||||
PIHOLE_DEPS=(cronie findutils libcap nmap-ncat lshw bash-completion)
|
||||
|
||||
# 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
|
||||
else
|
||||
# we cannot install required packages
|
||||
|
@ -413,6 +453,76 @@ package_manager_detect() {
|
|||
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
|
||||
dpkg-deb --build --root-owner-group "${tempdir}" pihole-meta.deb
|
||||
|
||||
# Move back into the directory the user started in
|
||||
popd &> /dev/null || return 1
|
||||
fi
|
||||
|
||||
if 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
|
||||
rpmbuild -bb "${tempdir}"/SPECS/pihole-meta.spec --define "_topdir ${tempdir}"
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# Remove the build directory
|
||||
rm -rf "${tempdir}"
|
||||
}
|
||||
|
||||
# A function for checking if a directory is a git repository
|
||||
is_repo() {
|
||||
# Use a named, local variable instead of the vague $1, which is the first argument passed to this function
|
||||
|
@ -1390,60 +1500,29 @@ notify_package_updates_available() {
|
|||
}
|
||||
|
||||
install_dependent_packages() {
|
||||
# Install meta dependency package
|
||||
|
||||
# Install packages passed in via argument array
|
||||
# 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.
|
||||
# Install Debian/Ubuntu packages
|
||||
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)
|
||||
for i in "$@"; do
|
||||
printf " %b Checking for %s..." "${INFO}" "${i}"
|
||||
if dpkg-query -W -f='${Status}' "${i}" 2>/dev/null | grep "ok installed" &>/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
|
||||
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
|
||||
if [ -f /tmp/pihole-meta.deb ]; then
|
||||
eval "${PKG_INSTALL}" "/tmp/pihole-meta.deb"
|
||||
rm /tmp/pihole-meta.deb
|
||||
else
|
||||
printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}"
|
||||
return 1
|
||||
fi
|
||||
printf "\\n"
|
||||
return 0
|
||||
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}"
|
||||
if is_command rpm; then
|
||||
if [ -f /tmp/pihole-meta.rpm ]; then
|
||||
eval "${PKG_INSTALL}" "/tmp/pihole-meta.rpm"
|
||||
rm /tmp/pihole-meta.rpm
|
||||
else
|
||||
printf "%b %b Checking for %s (will be installed)\\n" "${OVER}" "${INFO}" "${i}"
|
||||
installArray+=("${i}")
|
||||
printf " %b Error: Unable to find Pi-hole dependency meta package.\\n" "${COL_LIGHT_RED}"
|
||||
return 1
|
||||
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"
|
||||
return 0
|
||||
|
@ -1606,15 +1685,6 @@ installPihole() {
|
|||
exit 1
|
||||
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_pihole_lighttpd_configs
|
||||
|
||||
|
@ -2269,9 +2339,12 @@ main() {
|
|||
# Notify user of package availability
|
||||
notify_package_updates_available
|
||||
|
||||
# Install packages necessary to perform os_check
|
||||
printf " %b Checking for / installing required dependencies for OS Check...\\n" "${INFO}"
|
||||
install_dependent_packages "${OS_CHECK_COMMON_DEPS[@]}" "${OS_CHECK_DEPS[@]}"
|
||||
# Build dependency package
|
||||
build_dependency_package
|
||||
|
||||
# Install Pi-hole dependencies
|
||||
printf " %b Installing required dependencies ...\\n" "${INFO}"
|
||||
install_dependent_packages
|
||||
|
||||
# Check that the installed OS is officially supported - display warning if not
|
||||
os_check
|
||||
|
@ -2286,10 +2359,6 @@ main() {
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Install packages used by this installation script
|
||||
printf " %b Checking for / installing required dependencies for this install script...\\n" "${INFO}"
|
||||
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,
|
||||
|
@ -2331,13 +2400,6 @@ main() {
|
|||
# Download or update the scripts by updating the appropriate git 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_pihole_user
|
||||
|
@ -2355,6 +2417,15 @@ main() {
|
|||
# Install and log everything to a file
|
||||
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_to_install_log
|
||||
|
||||
|
|
|
@ -38,68 +38,25 @@ fi
|
|||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||
SKIP_INSTALL="true"
|
||||
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
|
||||
|
||||
# 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
|
||||
if [ -x "$(command -v apt-get)" ]; then
|
||||
# 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
|
||||
removeMetaPackage() {
|
||||
# Purge Pi-hole meta package
|
||||
echo ""
|
||||
for i in "${DEPS[@]}"; do
|
||||
if package_check "${i}" > /dev/null; then
|
||||
while true; do
|
||||
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
|
||||
echo -ne " ${INFO} Removing Pi-hole meta package...";
|
||||
eval "${SUDO}" "${PKG_REMOVE}" "pihole-meta" &> /dev/null;
|
||||
echo -e "${OVER} ${INFO} Removed Pi-hole meta package";
|
||||
|
||||
# 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
|
||||
echo -ne " ${INFO} Removing Web Interface..."
|
||||
${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 [ -d "/var/www/html" ]; then
|
||||
|
@ -126,45 +83,6 @@ removeNoPurge() {
|
|||
echo -e " ${TICK} Removed /etc/cron.d/pihole"
|
||||
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/*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
|
||||
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}"
|
||||
}
|
||||
|
||||
######### SCRIPT ###########
|
||||
echo -e " ${INFO} Be sure to confirm if any dependencies should not be removed"
|
||||
while true; do
|
||||
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
|
||||
removeMetaPackage
|
||||
removePiholeFiles
|
||||
|
|
|
@ -8,7 +8,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -6,7 +6,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -6,7 +6,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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
|
||||
|
||||
RUN true && \
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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 DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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 DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ 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/
|
||||
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 DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
|
|
|
@ -5,9 +5,8 @@ import subprocess
|
|||
from textwrap import dedent
|
||||
|
||||
IMAGE = "pytest_pihole:test_container"
|
||||
|
||||
tick_box = "[\x1b[1;32m\u2713\x1b[0m]"
|
||||
cross_box = "[\x1b[1;31m\u2717\x1b[0m]"
|
||||
tick_box = "[✓]"
|
||||
cross_box = "[✗]"
|
||||
info_box = "[i]"
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ from .conftest import (
|
|||
run_script,
|
||||
)
|
||||
|
||||
FTL_BRANCH = "development-v6"
|
||||
FTL_BRANCH = "development"
|
||||
|
||||
|
||||
def test_supported_package_manager(host):
|
||||
|
@ -480,8 +480,8 @@ def test_os_check_fails(host):
|
|||
"""
|
||||
source /opt/pihole/basic-install.sh
|
||||
package_manager_detect
|
||||
install_dependent_packages ${OS_CHECK_DEPS[@]}
|
||||
install_dependent_packages ${INSTALLER_DEPS[@]}
|
||||
build_dependency_package
|
||||
install_dependent_packages
|
||||
cat <<EOT > /etc/os-release
|
||||
ID=UnsupportedOS
|
||||
VERSION_ID="2"
|
||||
|
@ -504,8 +504,8 @@ def test_os_check_passes(host):
|
|||
"""
|
||||
source /opt/pihole/basic-install.sh
|
||||
package_manager_detect
|
||||
install_dependent_packages ${OS_CHECK_DEPS[@]}
|
||||
install_dependent_packages ${INSTALLER_DEPS[@]}
|
||||
build_dependency_package
|
||||
install_dependent_packages
|
||||
"""
|
||||
)
|
||||
detectOS = host.run(
|
||||
|
@ -518,21 +518,6 @@ def test_os_check_passes(host):
|
|||
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):
|
||||
"""Confirms OS is able to install the required packages for Pi-hole"""
|
||||
mock_command("dialog", {"*": ("", "0")}, host)
|
||||
|
@ -540,7 +525,8 @@ def test_package_manager_has_pihole_deps(host):
|
|||
"""
|
||||
source /opt/pihole/basic-install.sh
|
||||
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
|
||||
|
||||
|
||||
def test_package_manager_has_web_deps(host):
|
||||
"""Confirms OS is able to install the required packages for web"""
|
||||
def test_meta_package_uninstall(host):
|
||||
"""Confirms OS is able to install and uninstall the Pi-hole meta package"""
|
||||
mock_command("dialog", {"*": ("", "0")}, host)
|
||||
output = host.run(
|
||||
install = host.run(
|
||||
"""
|
||||
source /opt/pihole/basic-install.sh
|
||||
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
|
||||
assert output.rc == 0
|
||||
uninstall = host.run(
|
||||
"""
|
||||
source /opt/pihole/uninstall.sh
|
||||
removeMetaPackage
|
||||
"""
|
||||
)
|
||||
assert uninstall.rc == 0
|
||||
|
|
|
@ -41,7 +41,7 @@ def test_setFTLConfigValue_getFTLConfigValue(host):
|
|||
source /opt/pihole/basic-install.sh
|
||||
create_pihole_user
|
||||
funcOutput=$(get_binary_name)
|
||||
echo "development-v6" > /etc/pihole/ftlbranch
|
||||
echo "development" > /etc/pihole/ftlbranch
|
||||
binary="pihole-FTL${funcOutput##*pihole-FTL}"
|
||||
theRest="${funcOutput%pihole-FTL*}"
|
||||
FTLdetect "${binary}" "${theRest}"
|
||||
|
|
Loading…
Reference in a new issue