Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Warner <me@adamwarner.co.uk>2021-09-29 23:45:58 +0300
committerGitHub <noreply@github.com>2021-09-29 23:45:58 +0300
commitdad6247cb0c90fe8cc1ad541e0ccf8f02e1dd2be (patch)
tree54df1e19fd37fb6888d7e3d31b7cb8164fce9926
parent2673c2c0720fb3871a4c3cae6a3f38f9ccede24e (diff)
parent841222fa2107943939a6ae98e02f9b51147044d6 (diff)
Merge pull request #4347 from pi-hole/developmentv5.5
Pi-hole core v5.5
-rw-r--r--advanced/01-pihole.conf2
-rwxr-xr-xadvanced/Scripts/update.sh4
-rwxr-xr-xautomated install/basic-install.sh178
-rwxr-xr-xgravity.sh2
-rw-r--r--test/test_automated_install.py2
-rw-r--r--test/test_centos_7_support.py3
-rw-r--r--test/test_centos_8_support.py3
-rw-r--r--test/test_centos_common_support.py5
-rw-r--r--test/test_fedora_support.py1
9 files changed, 112 insertions, 88 deletions
diff --git a/advanced/01-pihole.conf b/advanced/01-pihole.conf
index e243e91a..02bc93bf 100644
--- a/advanced/01-pihole.conf
+++ b/advanced/01-pihole.conf
@@ -39,6 +39,4 @@ cache-size=@CACHE_SIZE@
log-queries
log-facility=/var/log/pihole.log
-local-ttl=2
-
log-async
diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh
index f833fc2f..dae04861 100755
--- a/advanced/Scripts/update.sh
+++ b/advanced/Scripts/update.sh
@@ -95,6 +95,10 @@ main() {
# shellcheck disable=1090,2154
source "${setupVars}"
+ # 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[@]}"
+
# This is unlikely
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
echo -e "\\n ${COL_LIGHT_RED}Error: Core Pi-hole repo is missing from system!"
diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh
index 34c0b4e7..e4c168ea 100755
--- a/automated install/basic-install.sh
+++ b/automated install/basic-install.sh
@@ -327,7 +327,7 @@ if is_command apt-get ; then
# Packages required to perfom the os_check (stored as an array)
OS_CHECK_DEPS=(grep dnsutils)
# Packages required to run this install script (stored as an array)
- INSTALLER_DEPS=(git "${iproute_pkg}" whiptail)
+ INSTALLER_DEPS=(git "${iproute_pkg}" whiptail ca-certificates)
# Packages required to run Pi-hole (stored as an array)
PIHOLE_DEPS=(cron curl iputils-ping lsof netcat psmisc sudo unzip idn2 sqlite3 libcap2-bin dns-root-data libcap2)
# Packages required for the Web admin interface (stored as an array)
@@ -373,95 +373,12 @@ elif is_command rpm ; then
PKG_INSTALL=("${PKG_MANAGER}" install -y)
PKG_COUNT="${PKG_MANAGER} check-update | egrep '(.i686|.x86|.noarch|.arm|.src)' | wc -l"
OS_CHECK_DEPS=(grep bind-utils)
- INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig)
+ INSTALLER_DEPS=(git iproute newt procps-ng which chkconfig ca-certificates)
PIHOLE_DEPS=(cronie curl findutils nmap-ncat sudo unzip libidn2 psmisc sqlite libcap lsof)
PIHOLE_WEB_DEPS=(lighttpd lighttpd-fastcgi php-common php-cli php-pdo php-xml php-json php-intl)
LIGHTTPD_USER="lighttpd"
LIGHTTPD_GROUP="lighttpd"
LIGHTTPD_CFG="lighttpd.conf.fedora"
- # If the host OS is Fedora,
- if grep -qiE 'fedora|fedberry' /etc/redhat-release; then
- # all required packages should be available by default with the latest fedora release
- : # continue
- # or if host OS is CentOS,
- elif grep -qiE 'centos|scientific' /etc/redhat-release; then
- # Pi-Hole currently supports CentOS 7+ with PHP7+
- SUPPORTED_CENTOS_VERSION=7
- SUPPORTED_CENTOS_PHP_VERSION=7
- # Check current CentOS major release version
- CURRENT_CENTOS_VERSION=$(grep -oP '(?<= )[0-9]+(?=\.?)' /etc/redhat-release)
- # Check if CentOS version is supported
- if [[ $CURRENT_CENTOS_VERSION -lt $SUPPORTED_CENTOS_VERSION ]]; then
- printf " %b CentOS %s is not supported.\\n" "${CROSS}" "${CURRENT_CENTOS_VERSION}"
- printf " Please update to CentOS release %s or later.\\n" "${SUPPORTED_CENTOS_VERSION}"
- # exit the installer
- exit
- fi
- # php-json is not required on CentOS 7 as it is already compiled into php
- # verifiy via `php -m | grep json`
- if [[ $CURRENT_CENTOS_VERSION -eq 7 ]]; then
- # create a temporary array as arrays are not designed for use as mutable data structures
- CENTOS7_PIHOLE_WEB_DEPS=()
- for i in "${!PIHOLE_WEB_DEPS[@]}"; do
- if [[ ${PIHOLE_WEB_DEPS[i]} != "php-json" ]]; then
- CENTOS7_PIHOLE_WEB_DEPS+=( "${PIHOLE_WEB_DEPS[i]}" )
- fi
- done
- # re-assign the clean dependency array back to PIHOLE_WEB_DEPS
- PIHOLE_WEB_DEPS=("${CENTOS7_PIHOLE_WEB_DEPS[@]}")
- unset CENTOS7_PIHOLE_WEB_DEPS
- fi
- # CentOS requires the EPEL repository to gain access to Fedora packages
- EPEL_PKG="epel-release"
- rpm -q ${EPEL_PKG} &> /dev/null || rc=$?
- if [[ $rc -ne 0 ]]; then
- printf " %b Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)\\n" "${INFO}"
- "${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null
- printf " %b Installed %s\\n" "${TICK}" "${EPEL_PKG}"
- fi
-
- # The default php on CentOS 7.x is 5.4 which is EOL
- # Check if the version of PHP available via installed repositories is >= to PHP 7
- AVAILABLE_PHP_VERSION=$("${PKG_MANAGER}" info php | grep -i version | grep -o '[0-9]\+' | head -1)
- if [[ $AVAILABLE_PHP_VERSION -ge $SUPPORTED_CENTOS_PHP_VERSION ]]; then
- # Since PHP 7 is available by default, install via default PHP package names
- : # do nothing as PHP is current
- else
- REMI_PKG="remi-release"
- REMI_REPO="remi-php72"
- rpm -q ${REMI_PKG} &> /dev/null || rc=$?
- if [[ $rc -ne 0 ]]; then
- # The PHP version available via default repositories is older than version 7
- if ! whiptail --defaultno --title "PHP 7 Update (recommended)" --yesno "PHP 7.x is recommended for both security and language features.\\nWould you like to install PHP7 via Remi's RPM repository?\\n\\nSee: https://rpms.remirepo.net for more information" "${r}" "${c}"; then
- # User decided to NOT update PHP from REMI, attempt to install the default available PHP version
- printf " %b User opt-out of PHP 7 upgrade on CentOS. Deprecated PHP may be in use.\\n" "${INFO}"
- : # continue with unsupported php version
- else
- printf " %b Enabling Remi's RPM repository (https://rpms.remirepo.net)\\n" "${INFO}"
- "${PKG_INSTALL[@]}" "https://rpms.remirepo.net/enterprise/${REMI_PKG}-$(rpm -E '%{rhel}').rpm" &> /dev/null
- # enable the PHP 7 repository via yum-config-manager (provided by yum-utils)
- "${PKG_INSTALL[@]}" "yum-utils" &> /dev/null
- yum-config-manager --enable ${REMI_REPO} &> /dev/null
- printf " %b Remi's RPM repository has been enabled for PHP7\\n" "${TICK}"
- # trigger an install/update of PHP to ensure previous version of PHP is updated from REMI
- if "${PKG_INSTALL[@]}" "php-cli" &> /dev/null; then
- printf " %b PHP7 installed/updated via Remi's RPM repository\\n" "${TICK}"
- else
- printf " %b There was a problem updating to PHP7 via Remi's RPM repository\\n" "${CROSS}"
- exit 1
- fi
- fi
- fi
- fi
- else
- # Warn user of unsupported version of Fedora or CentOS
- if ! whiptail --defaultno --title "Unsupported RPM based distribution" --yesno "Would you like to continue installation on an unsupported RPM based distribution?\\n\\nPlease ensure the following packages have been installed manually:\\n\\n- lighttpd\\n- lighttpd-fastcgi\\n- PHP version 7+" "${r}" "${c}"; then
- printf " %b Aborting installation due to unsupported RPM based distribution\\n" "${CROSS}"
- exit
- else
- printf " %b Continuing installation with unsupported RPM based distribution\\n" "${INFO}"
- fi
- fi
# If neither apt-get or yum/dnf package managers were found
else
@@ -472,6 +389,90 @@ else
fi
}
+select_rpm_php(){
+# If the host OS is Fedora,
+if grep -qiE 'fedora|fedberry' /etc/redhat-release; then
+ # all required packages should be available by default with the latest fedora release
+ : # continue
+# or if host OS is CentOS,
+elif grep -qiE 'centos|scientific' /etc/redhat-release; then
+ # Pi-Hole currently supports CentOS 7+ with PHP7+
+ SUPPORTED_CENTOS_VERSION=7
+ SUPPORTED_CENTOS_PHP_VERSION=7
+ # Check current CentOS major release version
+ CURRENT_CENTOS_VERSION=$(grep -oP '(?<= )[0-9]+(?=\.?)' /etc/redhat-release)
+ # Check if CentOS version is supported
+ if [[ $CURRENT_CENTOS_VERSION -lt $SUPPORTED_CENTOS_VERSION ]]; then
+ printf " %b CentOS %s is not supported.\\n" "${CROSS}" "${CURRENT_CENTOS_VERSION}"
+ printf " Please update to CentOS release %s or later.\\n" "${SUPPORTED_CENTOS_VERSION}"
+ # exit the installer
+ exit
+ fi
+ # php-json is not required on CentOS 7 as it is already compiled into php
+ # verifiy via `php -m | grep json`
+ if [[ $CURRENT_CENTOS_VERSION -eq 7 ]]; then
+ # create a temporary array as arrays are not designed for use as mutable data structures
+ CENTOS7_PIHOLE_WEB_DEPS=()
+ for i in "${!PIHOLE_WEB_DEPS[@]}"; do
+ if [[ ${PIHOLE_WEB_DEPS[i]} != "php-json" ]]; then
+ CENTOS7_PIHOLE_WEB_DEPS+=( "${PIHOLE_WEB_DEPS[i]}" )
+ fi
+ done
+ # re-assign the clean dependency array back to PIHOLE_WEB_DEPS
+ PIHOLE_WEB_DEPS=("${CENTOS7_PIHOLE_WEB_DEPS[@]}")
+ unset CENTOS7_PIHOLE_WEB_DEPS
+ fi
+ # CentOS requires the EPEL repository to gain access to Fedora packages
+ EPEL_PKG="epel-release"
+ rpm -q ${EPEL_PKG} &> /dev/null || rc=$?
+ if [[ $rc -ne 0 ]]; then
+ printf " %b Enabling EPEL package repository (https://fedoraproject.org/wiki/EPEL)\\n" "${INFO}"
+ "${PKG_INSTALL[@]}" ${EPEL_PKG} &> /dev/null
+ printf " %b Installed %s\\n" "${TICK}" "${EPEL_PKG}"
+ fi
+
+ # The default php on CentOS 7.x is 5.4 which is EOL
+ # Check if the version of PHP available via installed repositories is >= to PHP 7
+ AVAILABLE_PHP_VERSION=$("${PKG_MANAGER}" info php | grep -i version | grep -o '[0-9]\+' | head -1)
+ if [[ $AVAILABLE_PHP_VERSION -ge $SUPPORTED_CENTOS_PHP_VERSION ]]; then
+ # Since PHP 7 is available by default, install via default PHP package names
+ : # do nothing as PHP is current
+ else
+ REMI_PKG="remi-release"
+ REMI_REPO="remi-php72"
+ rpm -q ${REMI_PKG} &> /dev/null || rc=$?
+ if [[ $rc -ne 0 ]]; then
+ # The PHP version available via default repositories is older than version 7
+ if ! whiptail --defaultno --title "PHP 7 Update (recommended)" --yesno "PHP 7.x is recommended for both security and language features.\\nWould you like to install PHP7 via Remi's RPM repository?\\n\\nSee: https://rpms.remirepo.net for more information" "${r}" "${c}"; then
+ # User decided to NOT update PHP from REMI, attempt to install the default available PHP version
+ printf " %b User opt-out of PHP 7 upgrade on CentOS. Deprecated PHP may be in use.\\n" "${INFO}"
+ : # continue with unsupported php version
+ else
+ printf " %b Enabling Remi's RPM repository (https://rpms.remirepo.net)\\n" "${INFO}"
+ "${PKG_INSTALL[@]}" "https://rpms.remirepo.net/enterprise/${REMI_PKG}-$(rpm -E '%{rhel}').rpm" &> /dev/null
+ # enable the PHP 7 repository via yum-config-manager (provided by yum-utils)
+ "${PKG_INSTALL[@]}" "yum-utils" &> /dev/null
+ yum-config-manager --enable ${REMI_REPO} &> /dev/null
+ printf " %b Remi's RPM repository has been enabled for PHP7\\n" "${TICK}"
+ # trigger an install/update of PHP to ensure previous version of PHP is updated from REMI
+ if "${PKG_INSTALL[@]}" "php-cli" &> /dev/null; then
+ printf " %b PHP7 installed/updated via Remi's RPM repository\\n" "${TICK}"
+ else
+ printf " %b There was a problem updating to PHP7 via Remi's RPM repository\\n" "${CROSS}"
+ exit 1
+ fi
+ fi
+ fi # Warn user of unsupported version of Fedora or CentOS
+ if ! whiptail --defaultno --title "Unsupported RPM based distribution" --yesno "Would you like to continue installation on an unsupported RPM based distribution?\\n\\nPlease ensure the following packages have been installed manually:\\n\\n- lighttpd\\n- lighttpd-fastcgi\\n- PHP version 7+" "${r}" "${c}"; then
+ printf " %b Aborting installation due to unsupported RPM based distribution\\n" "${CROSS}"
+ exit
+ else
+ printf " %b Continuing installation with unsupported RPM based distribution\\n" "${INFO}"
+ fi
+fi
+fi
+}
+
# 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
@@ -1813,6 +1814,8 @@ finalExports() {
echo "INSTALL_WEB_INTERFACE=${INSTALL_WEB_INTERFACE}"
echo "LIGHTTPD_ENABLED=${LIGHTTPD_ENABLED}"
echo "CACHE_SIZE=${CACHE_SIZE}"
+ echo "DNS_FQDN_REQUIRED=true"
+ echo "DNS_BOGUS_PRIV=true"
}>> "${setupVars}"
chmod 644 "${setupVars}"
@@ -2547,6 +2550,11 @@ main() {
printf " %b Checking for / installing Required dependencies for this install script...\\n" "${INFO}"
install_dependent_packages "${INSTALLER_DEPS[@]}"
+ #In case of RPM based distro, select the proper PHP version
+ if [[ "$PKG_MANAGER" == "yum" || "$PKG_MANAGER" == "dnf" ]] ; then
+ select_rpm_php
+ fi
+
# Check if SELinux is Enforcing
checkSelinux
diff --git a/gravity.sh b/gravity.sh
index ff02e9f3..99d1bcda 100755
--- a/gravity.sh
+++ b/gravity.sh
@@ -122,7 +122,7 @@ gravity_swap_databases() {
gravityBlocks=$(stat --format "%b" ${gravityDBfile})
# Only keep the old database if available disk space is at least twice the size of the existing gravity.db.
# Better be safe than sorry...
- if [ "${availableBlocks}" -gt "$(("${gravityBlocks}" * 2))" ] && [ -f "${gravityDBfile}" ]; then
+ if [ "${availableBlocks}" -gt "$((gravityBlocks * 2))" ] && [ -f "${gravityDBfile}" ]; then
echo -e " ${TICK} The old database remains available."
mv "${gravityDBfile}" "${gravityOLDfile}"
else
diff --git a/test/test_automated_install.py b/test/test_automated_install.py
index 593c19d2..9938dd99 100644
--- a/test/test_automated_install.py
+++ b/test/test_automated_install.py
@@ -618,6 +618,7 @@ def test_package_manager_has_pihole_deps(Pihole):
output = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
install_dependent_packages ${PIHOLE_DEPS[@]}
''')
@@ -631,6 +632,7 @@ def test_package_manager_has_web_deps(Pihole):
output = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
install_dependent_packages ${PIHOLE_WEB_DEPS[@]}
''')
diff --git a/test/test_centos_7_support.py b/test/test_centos_7_support.py
index ed99231a..14f62637 100644
--- a/test/test_centos_7_support.py
+++ b/test/test_centos_7_support.py
@@ -12,6 +12,7 @@ def test_php_upgrade_default_optout_centos_eq_7(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
'Deprecated PHP may be in use.')
@@ -30,6 +31,7 @@ def test_php_upgrade_user_optout_centos_eq_7(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
'Deprecated PHP may be in use.')
@@ -48,6 +50,7 @@ def test_php_upgrade_user_optin_centos_eq_7(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
assert 'opt-out' not in package_manager_detect.stdout
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
diff --git a/test/test_centos_8_support.py b/test/test_centos_8_support.py
index b8ad9607..bbdbb765 100644
--- a/test/test_centos_8_support.py
+++ b/test/test_centos_8_support.py
@@ -13,6 +13,7 @@ def test_php_upgrade_default_continue_centos_gte_8(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
' Deprecated PHP may be in use.')
@@ -33,6 +34,7 @@ def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.'
' Deprecated PHP may be in use.')
@@ -53,6 +55,7 @@ def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
assert 'opt-out' not in package_manager_detect.stdout
unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository '
diff --git a/test/test_centos_common_support.py b/test/test_centos_common_support.py
index 8412173d..0b36cbae 100644
--- a/test/test_centos_common_support.py
+++ b/test/test_centos_common_support.py
@@ -16,6 +16,7 @@ def test_release_supported_version_check_centos(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = cross_box + (' CentOS 6 is not supported.')
assert expected_stdout in package_manager_detect.stdout
@@ -30,6 +31,7 @@ def test_enable_epel_repository_centos(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = info_box + (' Enabling EPEL package repository '
'(https://fedoraproject.org/wiki/EPEL)')
@@ -54,6 +56,7 @@ def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
'Deprecated PHP may be in use.')
@@ -78,6 +81,7 @@ def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
'Deprecated PHP may be in use.')
@@ -102,6 +106,7 @@ def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
install_dependent_packages PIHOLE_WEB_DEPS[@]
''')
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
diff --git a/test/test_fedora_support.py b/test/test_fedora_support.py
index a2ac4c71..3ad84be5 100644
--- a/test/test_fedora_support.py
+++ b/test/test_fedora_support.py
@@ -6,6 +6,7 @@ def test_epel_and_remi_not_installed_fedora(Pihole):
package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
+ select_rpm_php
''')
assert package_manager_detect.stdout == ''