diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index 72ba294e..4f32382e 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -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 diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 8f5b9879..b2bbb219 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -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 < +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 </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 diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index ac06da73..a073c319 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -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 diff --git a/test/_centos_9.Dockerfile b/test/_centos_9.Dockerfile index 7e3c5b3a..a5e7cf0b 100644 --- a/test/_centos_9.Dockerfile +++ b/test/_centos_9.Dockerfile @@ -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 && \ diff --git a/test/_debian_11.Dockerfile b/test/_debian_11.Dockerfile index cb7d27cc..b8107244 100644 --- a/test/_debian_11.Dockerfile +++ b/test/_debian_11.Dockerfile @@ -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 && \ diff --git a/test/_debian_12.Dockerfile b/test/_debian_12.Dockerfile index 50d709b1..7446711a 100644 --- a/test/_debian_12.Dockerfile +++ b/test/_debian_12.Dockerfile @@ -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 && \ diff --git a/test/_fedora_40.Dockerfile b/test/_fedora_40.Dockerfile index e4879c92..20102a10 100644 --- a/test/_fedora_40.Dockerfile +++ b/test/_fedora_40.Dockerfile @@ -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 && \ diff --git a/test/_fedora_41.Dockerfile b/test/_fedora_41.Dockerfile index 59858f4e..bf5fe5d5 100644 --- a/test/_fedora_41.Dockerfile +++ b/test/_fedora_41.Dockerfile @@ -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 && \ diff --git a/test/_ubuntu_20.Dockerfile b/test/_ubuntu_20.Dockerfile index 64d4f415..75c12673 100644 --- a/test/_ubuntu_20.Dockerfile +++ b/test/_ubuntu_20.Dockerfile @@ -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 && \ diff --git a/test/_ubuntu_22.Dockerfile b/test/_ubuntu_22.Dockerfile index 34faa361..9206a46a 100644 --- a/test/_ubuntu_22.Dockerfile +++ b/test/_ubuntu_22.Dockerfile @@ -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 diff --git a/test/_ubuntu_23.Dockerfile b/test/_ubuntu_23.Dockerfile index ea0ad245..4f88be7d 100644 --- a/test/_ubuntu_23.Dockerfile +++ b/test/_ubuntu_23.Dockerfile @@ -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 diff --git a/test/_ubuntu_24.Dockerfile b/test/_ubuntu_24.Dockerfile index 4d581cd3..4cab43de 100644 --- a/test/_ubuntu_24.Dockerfile +++ b/test/_ubuntu_24.Dockerfile @@ -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 diff --git a/test/conftest.py b/test/conftest.py index 164e8de5..dcf49790 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -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]" diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index 0930f0af..19812122 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -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 < /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 diff --git a/test/test_any_utils.py b/test/test_any_utils.py index cf6cc7e6..0f9ae6d2 100644 --- a/test/test_any_utils.py +++ b/test/test_any_utils.py @@ -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}"