From b6137584194c8811db26cad855e54ef9b454ffec Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Sat, 30 Jul 2022 16:19:40 +0100 Subject: [PATCH] rename select_rpm_php and simplify it to remove code no longer needed (discussed internally removing the unsupported dialog here to match behaviour on non rpm distros) Signed-off-by: Adam Warner --- automated install/basic-install.sh | 50 +++--------------------------- test/test_any_automated_install.py | 4 +-- test/test_centos_8_support.py | 6 ++-- test/test_centos_common_support.py | 2 +- test/test_fedora_support.py | 2 +- 5 files changed, 11 insertions(+), 53 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index c43d0334..93db8149 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -375,22 +375,11 @@ package_manager_detect() { fi } -select_rpm_php(){ - local unsupported_dialog=0 - # 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|alma|rocky' /etc/redhat-release; then - SUPPORTED_CENTOS_VERSION=8 +check_epel_repo_required(){ + # If the host OS is centos (or a derivative), + if grep -qiE 'centos|scientific|alma|rocky' /etc/redhat-release; then # 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 - unsupported_dialog=1 - fi - if rpm -qa | grep -qi 'epel'; then printf " %b EPEL repository already installed\\n" "${TICK}" else @@ -400,37 +389,6 @@ select_rpm_php(){ "${PKG_INSTALL[@]}" ${EPEL_PKG} printf " %b Installed %s\\n" "${TICK}" "${EPEL_PKG}" fi - else - unsupported_dialog=1 - fi - - if [[ ${unsupported_dialog} -eq 1 ]];then - # Warn user of unsupported version of Fedora or CentOS - dialog --no-shadow --keep-tite \ - --title "Unsupported RPM based distribution" \ - --defaultno \ - --no-button "Exit" \ - --yes-button "Continue" \ - --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}" && result=0 || result=$? - - case ${result} in - # User chose to continue installation on an unsupported RPM based distribution - "${DIALOG_OK}") - printf " %b User opted to continue installation on an unsupported RPM based distribution.\\n" "${INFO}" - ;; - # User chose not to continue installation on an unsupported RPM based distribution - "${DIALOG_CANCEL}") - printf " %b User opted not to continue installation on an unsupported RPM based distribution.\\n" "${INFO}" - exit 1 - ;; - "${DIALOG_ESC}") - printf " %b Escape pressed, exiting installer at unsupported RPM based distribution dialog window\\n" "${CROSS}" - exit 1 - ;; - esac fi } @@ -2580,7 +2538,7 @@ main() { #In case of RPM based distro, select the proper PHP version if [[ "$PKG_MANAGER" == "yum" || "$PKG_MANAGER" == "dnf" ]] ; then - select_rpm_php + check_epel_repo_required fi diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index 61849f54..15608050 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -1117,7 +1117,7 @@ def test_package_manager_has_pihole_deps(host): output = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required install_dependent_packages ${PIHOLE_DEPS[@]} ''') @@ -1131,7 +1131,7 @@ def test_package_manager_has_web_deps(host): output = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required install_dependent_packages ${PIHOLE_WEB_DEPS[@]} ''') diff --git a/test/test_centos_8_support.py b/test/test_centos_8_support.py index 9adbe841..63f49360 100644 --- a/test/test_centos_8_support.py +++ b/test/test_centos_8_support.py @@ -13,7 +13,7 @@ def test_php_upgrade_default_continue_centos_gte_8(host): package_manager_detect = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required ''') unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' ' Deprecated PHP may be in use.') @@ -34,7 +34,7 @@ def test_php_upgrade_user_optout_skipped_centos_gte_8(host): package_manager_detect = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required ''') unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' ' Deprecated PHP may be in use.') @@ -55,7 +55,7 @@ def test_php_upgrade_user_optin_skipped_centos_gte_8(host): package_manager_detect = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required ''') 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 2a9b3822..4be29c65 100644 --- a/test/test_centos_common_support.py +++ b/test/test_centos_common_support.py @@ -14,7 +14,7 @@ def test_enable_epel_repository_centos(host): package_manager_detect = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required ''') expected_stdout = info_box + (' Enabling EPEL package repository ' '(https://fedoraproject.org/wiki/EPEL)') diff --git a/test/test_fedora_support.py b/test/test_fedora_support.py index 63fde90e..45a7c2eb 100644 --- a/test/test_fedora_support.py +++ b/test/test_fedora_support.py @@ -6,7 +6,7 @@ def test_epel_and_remi_not_installed_fedora(host): package_manager_detect = host.run(''' source /opt/pihole/basic-install.sh package_manager_detect - select_rpm_php + check_epel_repo_required ''') assert package_manager_detect.stdout == ''