From 24b4aabae95397fd8521ac804ff87c5ec3ff1338 Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 29 Aug 2018 20:45:20 -0600 Subject: [PATCH 1/3] allow installer to continue with additional rpm based distros - FedBerry (Fedora based ARM image) - Scientific Linux (CentOS based) - Add prompt to continue installing on unsupported RPM based distros Signed-off-by: bcambl --- automated install/basic-install.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index a08bb3e3..6b8274be 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -244,17 +244,17 @@ elif command -v rpm &> /dev/null; then LIGHTTPD_GROUP="lighttpd" LIGHTTPD_CFG="lighttpd.conf.fedora" # If the host OS is Fedora, - if grep -qi 'fedora' /etc/redhat-release; then + if grep -qiE 'fedora|fedberry' /etc/redhat-release; then # all required packages should be available by default with the latest fedora release # ensure 'php-json' is installed on Fedora (installed as dependency on CentOS7 + Remi repository) PIHOLE_WEB_DEPS+=('php-json') # or if host OS is CentOS, - elif grep -qi 'centos' /etc/redhat-release; then + 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=$(rpm -q --queryformat '%{VERSION}' centos-release) + 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 echo -e " ${CROSS} CentOS $CURRENT_CENTOS_VERSION is not suported." @@ -305,13 +305,15 @@ elif command -v rpm &> /dev/null; then fi fi else - # If not a supported version of Fedora or CentOS, - echo -e " ${CROSS} Unsupported RPM based distribution" - # exit the installer - exit + # 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 + exit # exit the installer + else + : # continue with unsupported RPM distribution + fi fi -# If neither apt-get or rmp/dnf are found +# If neither apt-get or yum/dnf are found else # it's not an OS we can support, echo -e " ${CROSS} OS distribution not supported" From 6f8e8e98bbc4db871e14ed4a44c8ff7756c35121 Mon Sep 17 00:00:00 2001 From: bcambl Date: Wed, 29 Aug 2018 22:16:11 -0600 Subject: [PATCH 2/3] update centos version check test Signed-off-by: bcambl --- automated install/basic-install.sh | 2 +- test/test_centos_fedora_support.py | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 6b8274be..53a01b9d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -257,7 +257,7 @@ elif command -v rpm &> /dev/null; then 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 - echo -e " ${CROSS} CentOS $CURRENT_CENTOS_VERSION is not suported." + echo -e " ${CROSS} CentOS $CURRENT_CENTOS_VERSION is not supported." echo -e " Please update to CentOS release $SUPPORTED_CENTOS_VERSION or later" # exit the installer exit diff --git a/test/test_centos_fedora_support.py b/test/test_centos_fedora_support.py index 8318e44a..df53d73f 100644 --- a/test/test_centos_fedora_support.py +++ b/test/test_centos_fedora_support.py @@ -31,20 +31,13 @@ def test_release_supported_version_check_centos(Pihole): ''' confirms installer exits on unsupported releases of CentOS ''' - # mock CentOS release < 7 (unsupported) - mock_command_2( - 'rpm', - {"-q --queryformat '%{VERSION}' centos-release'": ( - '5', - '0' - )}, - Pihole - ) + # modify /etc/redhat-release to mock an unsupported CentOS release + Pihole.run('echo "CentOS Linux release 6.9" > /etc/redhat-release') distro_check = Pihole.run(''' source /opt/pihole/basic-install.sh distro_check ''') - expected_stdout = cross_box + (' CentOS is not suported.') + expected_stdout = cross_box + (' CentOS 6 is not supported.') assert expected_stdout in distro_check.stdout expected_stdout = 'Please update to CentOS release 7 or later' assert expected_stdout in distro_check.stdout From c58e3acc78bcd4845fcd31ac780d019e623e8983 Mon Sep 17 00:00:00 2001 From: bcambl Date: Fri, 31 Aug 2018 10:04:52 -0600 Subject: [PATCH 3/3] add unsupported RPM distro warnings Signed-off-by: bcambl --- automated install/basic-install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 53a01b9d..b5221fc3 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -307,13 +307,14 @@ elif command -v rpm &> /dev/null; then 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 + echo -e " ${CROSS} Aborting installation due to unsupported RPM based distribution" exit # exit the installer else - : # continue with unsupported RPM distribution + echo -e " ${INFO} Continuing installation with unsupported RPM based distribution" fi fi -# If neither apt-get or yum/dnf are found +# If neither apt-get or yum/dnf package managers were found else # it's not an OS we can support, echo -e " ${CROSS} OS distribution not supported"