From 3e73782f0e5b5463b5756f1e607e6b0cfee4411a Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 1 Dec 2020 10:02:31 +0000 Subject: [PATCH 1/8] Remove Travis CI config Create Github Actions config Split tox ini into one per supported distro so they can be run seperately Signed-off-by: Adam Warner --- .github/workflows/test.yml | 25 ++ .travis.yml | 5 - autotest | 1 - ...ntos_7.Dockerfile => _centos_7.Dockerfile} | 0 ...ntos_8.Dockerfile => _centos_8.Dockerfile} | 0 ...an_10.Dockerfile => _debian_10.Dockerfile} | 0 ...bian_9.Dockerfile => _debian_9.Dockerfile} | 0 ...ra_31.Dockerfile => _fedora_31.Dockerfile} | 0 ...ra_32.Dockerfile => _fedora_32.Dockerfile} | 0 ...tu_16.Dockerfile => _ubuntu_16.Dockerfile} | 2 +- ...tu_18.Dockerfile => _ubuntu_18.Dockerfile} | 0 ...tu_20.Dockerfile => _ubuntu_20.Dockerfile} | 0 test/conftest.py | 12 +- requirements.txt => test/requirements.txt | 0 setup.py => test/setup.py | 0 test/test_000_build_containers.py | 29 -- test/test_centos_7_support.py | 62 ++++ test/test_centos_8_support.py | 67 ++++ test/test_centos_common_support.py | 120 +++++++ test/test_centos_fedora_common_support.py | 66 ++++ test/test_centos_fedora_support.py | 327 ------------------ test/test_fedora_support.py | 24 ++ test/test_shellcheck.py | 18 - test/tox.centos_7.ini | 8 + test/tox.centos_8.ini | 8 + test/tox.debian_10.ini | 8 + test/tox.debian_9.ini | 8 + test/tox.fedora_31.ini | 8 + test/tox.fedora_32.ini | 8 + test/tox.ubuntu_16.ini | 8 + test/tox.ubuntu_18.ini | 8 + test/tox.ubuntu_20.ini | 8 + tox.ini | 16 - 33 files changed, 439 insertions(+), 407 deletions(-) create mode 100644 .github/workflows/test.yml delete mode 100644 .travis.yml delete mode 100755 autotest rename test/{centos_7.Dockerfile => _centos_7.Dockerfile} (100%) rename test/{centos_8.Dockerfile => _centos_8.Dockerfile} (100%) rename test/{debian_10.Dockerfile => _debian_10.Dockerfile} (100%) rename test/{debian_9.Dockerfile => _debian_9.Dockerfile} (100%) rename test/{fedora_31.Dockerfile => _fedora_31.Dockerfile} (100%) rename test/{fedora_32.Dockerfile => _fedora_32.Dockerfile} (100%) rename test/{ubuntu_16.Dockerfile => _ubuntu_16.Dockerfile} (92%) rename test/{ubuntu_18.Dockerfile => _ubuntu_18.Dockerfile} (100%) rename test/{ubuntu_20.Dockerfile => _ubuntu_20.Dockerfile} (100%) rename requirements.txt => test/requirements.txt (100%) rename setup.py => test/setup.py (100%) delete mode 100644 test/test_000_build_containers.py create mode 100644 test/test_centos_7_support.py create mode 100644 test/test_centos_8_support.py create mode 100644 test/test_centos_common_support.py create mode 100644 test/test_centos_fedora_common_support.py delete mode 100644 test/test_centos_fedora_support.py create mode 100644 test/test_fedora_support.py delete mode 100644 test/test_shellcheck.py create mode 100644 test/tox.centos_7.ini create mode 100644 test/tox.centos_8.ini create mode 100644 test/tox.debian_10.ini create mode 100644 test/tox.debian_9.ini create mode 100644 test/tox.fedora_31.ini create mode 100644 test/tox.fedora_32.ini create mode 100644 test/tox.ubuntu_16.ini create mode 100644 test/tox.ubuntu_18.ini create mode 100644 test/tox.ubuntu_20.ini delete mode 100644 tox.ini diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..9145e8a5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Test Supported Distributions + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + distro-test: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + strategy: + matrix: + distro: [debian_9, debian_10, ubuntu_16, ubuntu_18, ubuntu_20, centos_7, centos_8, fedora_31, fedora_32] + env: + DISTRO: ${{matrix.distro}} + steps: + - uses: actions/checkout@v1 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Install dependencies + run: pip install -r test/requirements.txt + - name: Test with tox + run: tox -c test/tox.${DISTRO}.ini diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3d80ab6e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -import: - - source: pi-hole/.github:/build-configs/core.yml@main - if: branch = master - - source: pi-hole/.github:/build-configs/core.yml@latest - if: branch != master diff --git a/autotest b/autotest deleted file mode 100755 index 3747cc0b..00000000 --- a/autotest +++ /dev/null @@ -1 +0,0 @@ -py.test -v -f test/ diff --git a/test/centos_7.Dockerfile b/test/_centos_7.Dockerfile similarity index 100% rename from test/centos_7.Dockerfile rename to test/_centos_7.Dockerfile diff --git a/test/centos_8.Dockerfile b/test/_centos_8.Dockerfile similarity index 100% rename from test/centos_8.Dockerfile rename to test/_centos_8.Dockerfile diff --git a/test/debian_10.Dockerfile b/test/_debian_10.Dockerfile similarity index 100% rename from test/debian_10.Dockerfile rename to test/_debian_10.Dockerfile diff --git a/test/debian_9.Dockerfile b/test/_debian_9.Dockerfile similarity index 100% rename from test/debian_9.Dockerfile rename to test/_debian_9.Dockerfile diff --git a/test/fedora_31.Dockerfile b/test/_fedora_31.Dockerfile similarity index 100% rename from test/fedora_31.Dockerfile rename to test/_fedora_31.Dockerfile diff --git a/test/fedora_32.Dockerfile b/test/_fedora_32.Dockerfile similarity index 100% rename from test/fedora_32.Dockerfile rename to test/_fedora_32.Dockerfile diff --git a/test/ubuntu_16.Dockerfile b/test/_ubuntu_16.Dockerfile similarity index 92% rename from test/ubuntu_16.Dockerfile rename to test/_ubuntu_16.Dockerfile index d1107082..a92bc6f6 100644 --- a/test/ubuntu_16.Dockerfile +++ b/test/_ubuntu_16.Dockerfile @@ -13,4 +13,4 @@ RUN true && \ ENV PH_TEST true -#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \ +#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \ \ No newline at end of file diff --git a/test/ubuntu_18.Dockerfile b/test/_ubuntu_18.Dockerfile similarity index 100% rename from test/ubuntu_18.Dockerfile rename to test/_ubuntu_18.Dockerfile diff --git a/test/ubuntu_20.Dockerfile b/test/_ubuntu_20.Dockerfile similarity index 100% rename from test/ubuntu_20.Dockerfile rename to test/_ubuntu_20.Dockerfile diff --git a/test/conftest.py b/test/conftest.py index cda861c1..aebf5173 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -70,15 +70,7 @@ def args(request): @pytest.fixture(params=[ - 'debian_9', - 'debian_10', - 'centos_7', - 'centos_8', - 'fedora_31', - 'fedora_32', - 'ubuntu_16', - 'ubuntu_18', - 'ubuntu_20' + 'test_container' ]) def tag(request): ''' @@ -161,4 +153,4 @@ def mock_command_2(script, args, container): def run_script(Pihole, script): result = Pihole.run(script) assert result.rc == 0 - return result + return result \ No newline at end of file diff --git a/requirements.txt b/test/requirements.txt similarity index 100% rename from requirements.txt rename to test/requirements.txt diff --git a/setup.py b/test/setup.py similarity index 100% rename from setup.py rename to test/setup.py diff --git a/test/test_000_build_containers.py b/test/test_000_build_containers.py deleted file mode 100644 index 3033249f..00000000 --- a/test/test_000_build_containers.py +++ /dev/null @@ -1,29 +0,0 @@ -''' This file starts with 000 to make it run first ''' -import pytest -import testinfra - -run_local = testinfra.get_backend( - "local://" -).get_module("Command").run - - -@pytest.mark.parametrize("image,tag", [ - ('test/debian_9.Dockerfile', 'pytest_pihole:debian_9'), - ('test/debian_10.Dockerfile', 'pytest_pihole:debian_10'), - ('test/centos_7.Dockerfile', 'pytest_pihole:centos_7'), - ('test/centos_8.Dockerfile', 'pytest_pihole:centos_8'), - ('test/fedora_31.Dockerfile', 'pytest_pihole:fedora_31'), - ('test/fedora_32.Dockerfile', 'pytest_pihole:fedora_32'), - ('test/ubuntu_16.Dockerfile', 'pytest_pihole:ubuntu_16'), - ('test/ubuntu_18.Dockerfile', 'pytest_pihole:ubuntu_18'), - ('test/ubuntu_20.Dockerfile', 'pytest_pihole:ubuntu_20'), -]) -# mark as 'build_stage' so we can ensure images are built first when tests -# are executed in parallel. (not required when tests are executed serially) -@pytest.mark.build_stage -def test_build_pihole_image(image, tag): - build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag)) - if build_cmd.rc != 0: - print(build_cmd.stdout) - print(build_cmd.stderr) - assert build_cmd.rc == 0 diff --git a/test/test_centos_7_support.py b/test/test_centos_7_support.py new file mode 100644 index 00000000..78cc6070 --- /dev/null +++ b/test/test_centos_7_support.py @@ -0,0 +1,62 @@ +import pytest +from .conftest import ( + tick_box, + info_box, + cross_box, + mock_command, +) + + +def test_php_upgrade_default_optout_centos_eq_7(Pihole): + ''' + confirms the default behavior to opt-out of installing PHP7 from REMI + ''' + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' + 'Deprecated PHP may be in use.') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_upgrade_user_optout_centos_eq_7(Pihole): + ''' + confirms installer behavior when user opt-out of installing PHP7 from REMI + (php not currently installed) + ''' + # Whiptail dialog returns Cancel for user prompt + mock_command('whiptail', {'*': ('', '1')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' + 'Deprecated PHP may be in use.') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_upgrade_user_optin_centos_eq_7(Pihole): + ''' + confirms installer behavior when user opt-in to installing PHP7 from REMI + (php not currently installed) + ''' + # Whiptail dialog returns Continue for user prompt + mock_command('whiptail', {'*': ('', '0')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + assert 'opt-out' not in distro_check.stdout + expected_stdout = info_box + (' Enabling Remi\'s RPM repository ' + '(https://rpms.remirepo.net)') + assert expected_stdout in distro_check.stdout + expected_stdout = tick_box + (' Remi\'s RPM repository has ' + 'been enabled for PHP7') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert remi_package.is_installed diff --git a/test/test_centos_8_support.py b/test/test_centos_8_support.py new file mode 100644 index 00000000..899cff2f --- /dev/null +++ b/test/test_centos_8_support.py @@ -0,0 +1,67 @@ +import pytest +from .conftest import ( + tick_box, + info_box, + cross_box, + mock_command, +) + + +def test_php_upgrade_default_continue_centos_gte_8(Pihole): + ''' + confirms the latest version of CentOS continues / does not optout + (should trigger on CentOS7 only) + ''' + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' + ' Deprecated PHP may be in use.') + assert unexpected_stdout not in distro_check.stdout + # ensure remi was not installed on latest CentOS + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole): + ''' + confirms installer skips user opt-out of installing PHP7 from REMI on + latest CentOS (should trigger on CentOS7 only) + (php not currently installed) + ''' + # Whiptail dialog returns Cancel for user prompt + mock_command('whiptail', {'*': ('', '1')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' + ' Deprecated PHP may be in use.') + assert unexpected_stdout not in distro_check.stdout + # ensure remi was not installed on latest CentOS + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole): + ''' + confirms installer skips user opt-in to installing PHP7 from REMI on + latest CentOS (should trigger on CentOS7 only) + (php not currently installed) + ''' + # Whiptail dialog returns Continue for user prompt + mock_command('whiptail', {'*': ('', '0')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + assert 'opt-out' not in distro_check.stdout + unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository ' + '(https://rpms.remirepo.net)') + assert unexpected_stdout not in distro_check.stdout + unexpected_stdout = tick_box + (' Remi\'s RPM repository has ' + 'been enabled for PHP7') + assert unexpected_stdout not in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed diff --git a/test/test_centos_common_support.py b/test/test_centos_common_support.py new file mode 100644 index 00000000..4490f220 --- /dev/null +++ b/test/test_centos_common_support.py @@ -0,0 +1,120 @@ +import pytest +from .conftest import ( + tick_box, + info_box, + cross_box, + mock_command, +) + + +def test_release_supported_version_check_centos(Pihole): + ''' + confirms installer exits on unsupported releases of CentOS + ''' + # 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 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 + + +def test_enable_epel_repository_centos(Pihole): + ''' + confirms the EPEL package repository is enabled when installed on CentOS + ''' + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + expected_stdout = info_box + (' Enabling EPEL package repository ' + '(https://fedoraproject.org/wiki/EPEL)') + assert expected_stdout in distro_check.stdout + expected_stdout = tick_box + ' Installed epel-release' + assert expected_stdout in distro_check.stdout + epel_package = Pihole.package('epel-release') + assert epel_package.is_installed + + +def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole): + ''' + confirms the default behavior to opt-out of upgrading to PHP7 from REMI + ''' + # first we will install the default php version to test installer behavior + php_install = Pihole.run('yum install -y php') + assert php_install.rc == 0 + php_package = Pihole.package('php') + default_centos_php_version = php_package.version.split('.')[0] + if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended + pytest.skip("Test deprecated . Detected default PHP version >= 7") + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' + 'Deprecated PHP may be in use.') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole): + ''' + confirms installer behavior when user opt-out to upgrade to PHP7 via REMI + ''' + # first we will install the default php version to test installer behavior + php_install = Pihole.run('yum install -y php') + assert php_install.rc == 0 + php_package = Pihole.package('php') + default_centos_php_version = php_package.version.split('.')[0] + if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended + pytest.skip("Test deprecated . Detected default PHP version >= 7") + # Whiptail dialog returns Cancel for user prompt + mock_command('whiptail', {'*': ('', '1')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' + 'Deprecated PHP may be in use.') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole): + ''' + confirms installer behavior when user opt-in to upgrade to PHP7 via REMI + ''' + # first we will install the default php version to test installer behavior + php_install = Pihole.run('yum install -y php') + assert php_install.rc == 0 + php_package = Pihole.package('php') + default_centos_php_version = php_package.version.split('.')[0] + if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended + pytest.skip("Test deprecated . Detected default PHP version >= 7") + # Whiptail dialog returns Continue for user prompt + mock_command('whiptail', {'*': ('', '0')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + install_dependent_packages PIHOLE_WEB_DEPS[@] + ''') + expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' + 'Deprecated PHP may be in use.') + assert expected_stdout not in distro_check.stdout + expected_stdout = info_box + (' Enabling Remi\'s RPM repository ' + '(https://rpms.remirepo.net)') + assert expected_stdout in distro_check.stdout + expected_stdout = tick_box + (' Remi\'s RPM repository has ' + 'been enabled for PHP7') + assert expected_stdout in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert remi_package.is_installed + updated_php_package = Pihole.package('php') + updated_php_version = updated_php_package.version.split('.')[0] + assert int(updated_php_version) == 7 \ No newline at end of file diff --git a/test/test_centos_fedora_common_support.py b/test/test_centos_fedora_common_support.py new file mode 100644 index 00000000..7338f0fc --- /dev/null +++ b/test/test_centos_fedora_common_support.py @@ -0,0 +1,66 @@ +import pytest +from .conftest import ( + tick_box, + info_box, + cross_box, + mock_command, +) + + +def mock_selinux_config(state, Pihole): + ''' + Creates a mock SELinux config file with expected content + ''' + # validate state string + valid_states = ['enforcing', 'permissive', 'disabled'] + assert state in valid_states + # getenforce returns the running state of SELinux + mock_command('getenforce', {'*': (state.capitalize(), '0')}, Pihole) + # create mock configuration with desired content + Pihole.run(''' + mkdir /etc/selinux + echo "SELINUX={state}" > /etc/selinux/config + '''.format(state=state.lower())) + + +def test_selinux_enforcing_exit(Pihole): + ''' + confirms installer prompts to exit when SELinux is Enforcing by default + ''' + mock_selinux_config("enforcing", Pihole) + check_selinux = Pihole.run(''' + source /opt/pihole/basic-install.sh + checkSelinux + ''') + expected_stdout = cross_box + ' Current SELinux: Enforcing' + assert expected_stdout in check_selinux.stdout + expected_stdout = 'SELinux Enforcing detected, exiting installer' + assert expected_stdout in check_selinux.stdout + assert check_selinux.rc == 1 + + +def test_selinux_permissive(Pihole): + ''' + confirms installer continues when SELinux is Permissive + ''' + mock_selinux_config("permissive", Pihole) + check_selinux = Pihole.run(''' + source /opt/pihole/basic-install.sh + checkSelinux + ''') + expected_stdout = tick_box + ' Current SELinux: Permissive' + assert expected_stdout in check_selinux.stdout + assert check_selinux.rc == 0 + +def test_selinux_disabled(Pihole): + ''' + confirms installer continues when SELinux is Disabled + ''' + mock_selinux_config("disabled", Pihole) + check_selinux = Pihole.run(''' + source /opt/pihole/basic-install.sh + checkSelinux + ''') + expected_stdout = tick_box + ' Current SELinux: Disabled' + assert expected_stdout in check_selinux.stdout + assert check_selinux.rc == 0 diff --git a/test/test_centos_fedora_support.py b/test/test_centos_fedora_support.py deleted file mode 100644 index 8dd0ee5f..00000000 --- a/test/test_centos_fedora_support.py +++ /dev/null @@ -1,327 +0,0 @@ -import pytest -from .conftest import ( - tick_box, - info_box, - cross_box, - mock_command, -) - - -def mock_selinux_config(state, Pihole): - ''' - Creates a mock SELinux config file with expected content - ''' - # validate state string - valid_states = ['enforcing', 'permissive', 'disabled'] - assert state in valid_states - # getenforce returns the running state of SELinux - mock_command('getenforce', {'*': (state.capitalize(), '0')}, Pihole) - # create mock configuration with desired content - Pihole.run(''' - mkdir /etc/selinux - echo "SELINUX={state}" > /etc/selinux/config - '''.format(state=state.lower())) - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ('fedora_31'), ('fedora_32'), ]) -def test_selinux_enforcing_exit(Pihole): - ''' - confirms installer prompts to exit when SELinux is Enforcing by default - ''' - mock_selinux_config("enforcing", Pihole) - check_selinux = Pihole.run(''' - source /opt/pihole/basic-install.sh - checkSelinux - ''') - expected_stdout = cross_box + ' Current SELinux: Enforcing' - assert expected_stdout in check_selinux.stdout - expected_stdout = 'SELinux Enforcing detected, exiting installer' - assert expected_stdout in check_selinux.stdout - assert check_selinux.rc == 1 - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ('fedora_31'), ('fedora_32'), ]) -def test_selinux_permissive(Pihole): - ''' - confirms installer continues when SELinux is Permissive - ''' - mock_selinux_config("permissive", Pihole) - check_selinux = Pihole.run(''' - source /opt/pihole/basic-install.sh - checkSelinux - ''') - expected_stdout = tick_box + ' Current SELinux: Permissive' - assert expected_stdout in check_selinux.stdout - assert check_selinux.rc == 0 - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ('fedora_31'), ('fedora_32'), ]) -def test_selinux_disabled(Pihole): - ''' - confirms installer continues when SELinux is Disabled - ''' - mock_selinux_config("disabled", Pihole) - check_selinux = Pihole.run(''' - source /opt/pihole/basic-install.sh - checkSelinux - ''') - expected_stdout = tick_box + ' Current SELinux: Disabled' - assert expected_stdout in check_selinux.stdout - assert check_selinux.rc == 0 - - -@pytest.mark.parametrize("tag", [('fedora_31'), ('fedora_32'), ]) -def test_epel_and_remi_not_installed_fedora(Pihole): - ''' - confirms installer does not attempt to install EPEL/REMI repositories - on Fedora - ''' - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - assert distro_check.stdout == '' - - epel_package = Pihole.package('epel-release') - assert not epel_package.is_installed - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ]) -def test_release_supported_version_check_centos(Pihole): - ''' - confirms installer exits on unsupported releases of CentOS - ''' - # 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 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 - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ]) -def test_enable_epel_repository_centos(Pihole): - ''' - confirms the EPEL package repository is enabled when installed on CentOS - ''' - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - expected_stdout = info_box + (' Enabling EPEL package repository ' - '(https://fedoraproject.org/wiki/EPEL)') - assert expected_stdout in distro_check.stdout - expected_stdout = tick_box + ' Installed epel-release' - assert expected_stdout in distro_check.stdout - epel_package = Pihole.package('epel-release') - assert epel_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ]) -def test_php_upgrade_default_optout_centos_eq_7(Pihole): - ''' - confirms the default behavior to opt-out of installing PHP7 from REMI - ''' - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' - 'Deprecated PHP may be in use.') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_8'), ]) -def test_php_upgrade_default_continue_centos_gte_8(Pihole): - ''' - confirms the latest version of CentOS continues / does not optout - (should trigger on CentOS7 only) - ''' - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' - ' Deprecated PHP may be in use.') - assert unexpected_stdout not in distro_check.stdout - # ensure remi was not installed on latest CentOS - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ]) -def test_php_upgrade_user_optout_centos_eq_7(Pihole): - ''' - confirms installer behavior when user opt-out of installing PHP7 from REMI - (php not currently installed) - ''' - # Whiptail dialog returns Cancel for user prompt - mock_command('whiptail', {'*': ('', '1')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' - 'Deprecated PHP may be in use.') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_8'), ]) -def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole): - ''' - confirms installer skips user opt-out of installing PHP7 from REMI on - latest CentOS (should trigger on CentOS7 only) - (php not currently installed) - ''' - # Whiptail dialog returns Cancel for user prompt - mock_command('whiptail', {'*': ('', '1')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' - ' Deprecated PHP may be in use.') - assert unexpected_stdout not in distro_check.stdout - # ensure remi was not installed on latest CentOS - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ]) -def test_php_upgrade_user_optin_centos_eq_7(Pihole): - ''' - confirms installer behavior when user opt-in to installing PHP7 from REMI - (php not currently installed) - ''' - # Whiptail dialog returns Continue for user prompt - mock_command('whiptail', {'*': ('', '0')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - assert 'opt-out' not in distro_check.stdout - expected_stdout = info_box + (' Enabling Remi\'s RPM repository ' - '(https://rpms.remirepo.net)') - assert expected_stdout in distro_check.stdout - expected_stdout = tick_box + (' Remi\'s RPM repository has ' - 'been enabled for PHP7') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_8'), ]) -def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole): - ''' - confirms installer skips user opt-in to installing PHP7 from REMI on - latest CentOS (should trigger on CentOS7 only) - (php not currently installed) - ''' - # Whiptail dialog returns Continue for user prompt - mock_command('whiptail', {'*': ('', '0')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - assert 'opt-out' not in distro_check.stdout - unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository ' - '(https://rpms.remirepo.net)') - assert unexpected_stdout not in distro_check.stdout - unexpected_stdout = tick_box + (' Remi\'s RPM repository has ' - 'been enabled for PHP7') - assert unexpected_stdout not in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ]) -def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole): - ''' - confirms the default behavior to opt-out of upgrading to PHP7 from REMI - ''' - # first we will install the default php version to test installer behavior - php_install = Pihole.run('yum install -y php') - assert php_install.rc == 0 - php_package = Pihole.package('php') - default_centos_php_version = php_package.version.split('.')[0] - if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended - pytest.skip("Test deprecated . Detected default PHP version >= 7") - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' - 'Deprecated PHP may be in use.') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ]) -def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole): - ''' - confirms installer behavior when user opt-out to upgrade to PHP7 via REMI - ''' - # first we will install the default php version to test installer behavior - php_install = Pihole.run('yum install -y php') - assert php_install.rc == 0 - php_package = Pihole.package('php') - default_centos_php_version = php_package.version.split('.')[0] - if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended - pytest.skip("Test deprecated . Detected default PHP version >= 7") - # Whiptail dialog returns Cancel for user prompt - mock_command('whiptail', {'*': ('', '1')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - ''') - expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' - 'Deprecated PHP may be in use.') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert not remi_package.is_installed - - -@pytest.mark.parametrize("tag", [('centos_7'), ('centos_8'), ]) -def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole): - ''' - confirms installer behavior when user opt-in to upgrade to PHP7 via REMI - ''' - # first we will install the default php version to test installer behavior - php_install = Pihole.run('yum install -y php') - assert php_install.rc == 0 - php_package = Pihole.package('php') - default_centos_php_version = php_package.version.split('.')[0] - if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended - pytest.skip("Test deprecated . Detected default PHP version >= 7") - # Whiptail dialog returns Continue for user prompt - mock_command('whiptail', {'*': ('', '0')}, Pihole) - distro_check = Pihole.run(''' - source /opt/pihole/basic-install.sh - distro_check - install_dependent_packages PIHOLE_WEB_DEPS[@] - ''') - expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. ' - 'Deprecated PHP may be in use.') - assert expected_stdout not in distro_check.stdout - expected_stdout = info_box + (' Enabling Remi\'s RPM repository ' - '(https://rpms.remirepo.net)') - assert expected_stdout in distro_check.stdout - expected_stdout = tick_box + (' Remi\'s RPM repository has ' - 'been enabled for PHP7') - assert expected_stdout in distro_check.stdout - remi_package = Pihole.package('remi-release') - assert remi_package.is_installed - updated_php_package = Pihole.package('php') - updated_php_version = updated_php_package.version.split('.')[0] - assert int(updated_php_version) == 7 diff --git a/test/test_fedora_support.py b/test/test_fedora_support.py new file mode 100644 index 00000000..a5823883 --- /dev/null +++ b/test/test_fedora_support.py @@ -0,0 +1,24 @@ +import pytest +from .conftest import ( + tick_box, + info_box, + cross_box, + mock_command, +) + + +def test_epel_and_remi_not_installed_fedora(Pihole): + ''' + confirms installer does not attempt to install EPEL/REMI repositories + on Fedora + ''' + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + assert distro_check.stdout == '' + + epel_package = Pihole.package('epel-release') + assert not epel_package.is_installed + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed diff --git a/test/test_shellcheck.py b/test/test_shellcheck.py deleted file mode 100644 index 919ad2b9..00000000 --- a/test/test_shellcheck.py +++ /dev/null @@ -1,18 +0,0 @@ -import testinfra - -run_local = testinfra.get_backend( - "local://" -).get_module("Command").run - - -def test_scripts_pass_shellcheck(): - ''' - Make sure shellcheck does not find anything wrong with our shell scripts - ''' - shellcheck = ("find . -type f -name 'update.sh' " - "| while read file; do " - "shellcheck -x \"$file\" -e SC1090,SC1091; " - "done;") - results = run_local(shellcheck) - print(results.stdout) - assert '' == results.stdout diff --git a/test/tox.centos_7.ini b/test/tox.centos_7.ini new file mode 100644 index 00000000..c2752698 --- /dev/null +++ b/test/tox.centos_7.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _centos_7.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py ./test_centos_7_support.py diff --git a/test/tox.centos_8.ini b/test/tox.centos_8.ini new file mode 100644 index 00000000..c8852bae --- /dev/null +++ b/test/tox.centos_8.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _centos_8.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_centos_common_support.py ./test_centos_8_support.py diff --git a/test/tox.debian_10.ini b/test/tox.debian_10.ini new file mode 100644 index 00000000..e8c5d746 --- /dev/null +++ b/test/tox.debian_10.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _debian_10.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py diff --git a/test/tox.debian_9.ini b/test/tox.debian_9.ini new file mode 100644 index 00000000..b33e9927 --- /dev/null +++ b/test/tox.debian_9.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _debian_9.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py diff --git a/test/tox.fedora_31.ini b/test/tox.fedora_31.ini new file mode 100644 index 00000000..36ab10ad --- /dev/null +++ b/test/tox.fedora_31.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _fedora_31.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_fedora_support.py diff --git a/test/tox.fedora_32.ini b/test/tox.fedora_32.ini new file mode 100644 index 00000000..c68e0757 --- /dev/null +++ b/test/tox.fedora_32.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _fedora_32.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py ./test_centos_fedora_common_support.py ./test_fedora_support.py diff --git a/test/tox.ubuntu_16.ini b/test/tox.ubuntu_16.ini new file mode 100644 index 00000000..6f484b6b --- /dev/null +++ b/test/tox.ubuntu_16.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _ubuntu_16.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py diff --git a/test/tox.ubuntu_18.ini b/test/tox.ubuntu_18.ini new file mode 100644 index 00000000..10d4ac09 --- /dev/null +++ b/test/tox.ubuntu_18.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _ubuntu_18.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py diff --git a/test/tox.ubuntu_20.ini b/test/tox.ubuntu_20.ini new file mode 100644 index 00000000..8b405b28 --- /dev/null +++ b/test/tox.ubuntu_20.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py37 + +[testenv] +whitelist_externals = docker +deps = -rrequirements.txt +commands = docker build -f _ubuntu_20.Dockerfile -t pytest_pihole:test_container ../ + pytest {posargs:-vv -n auto} ./test_automated_install.py diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 1142aea8..00000000 --- a/tox.ini +++ /dev/null @@ -1,16 +0,0 @@ -[tox] -envlist = py37 - -[testenv] -whitelist_externals = docker -deps = -rrequirements.txt -commands = docker build -f test/debian_9.Dockerfile -t pytest_pihole:debian_9 . - docker build -f test/debian_10.Dockerfile -t pytest_pihole:debian_10 . - docker build -f test/centos_7.Dockerfile -t pytest_pihole:centos_7 . - docker build -f test/centos_8.Dockerfile -t pytest_pihole:centos_8 . - docker build -f test/fedora_31.Dockerfile -t pytest_pihole:fedora_31 . - docker build -f test/fedora_32.Dockerfile -t pytest_pihole:fedora_32 . - docker build -f test/ubuntu_16.Dockerfile -t pytest_pihole:ubuntu_16 . - docker build -f test/ubuntu_18.Dockerfile -t pytest_pihole:ubuntu_18 . - docker build -f test/ubuntu_20.Dockerfile -t pytest_pihole:ubuntu_20 . - pytest {posargs:-vv -n auto} -m "not build_stage" ./test/ From 44d020a54c9a722619b7a56d089028b2cb0275f3 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 1 Dec 2020 10:09:16 +0000 Subject: [PATCH 2/8] Appease codefactor.io Signed-off-by: Adam Warner --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9145e8a5..8e19e550 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - distro: [debian_9, debian_10, ubuntu_16, ubuntu_18, ubuntu_20, centos_7, centos_8, fedora_31, fedora_32] + distro: [debian_9, debian_10, ubuntu_16, ubuntu_18, ubuntu_20, centos_7, centos_8, fedora_31, fedora_32] env: - DISTRO: ${{matrix.distro}} - steps: + DISTRO: ${{matrix.distro}} + steps: - uses: actions/checkout@v1 - name: Set up Python 3.7 uses: actions/setup-python@v2 From d1539335bca135470d3b5fd8039c6e7600c802c3 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 1 Dec 2020 10:13:36 +0000 Subject: [PATCH 3/8] appease stickler-ci Signed-off-by: Adam Warner --- test/conftest.py | 2 +- test/test_centos_7_support.py | 2 -- test/test_centos_8_support.py | 2 -- test/test_centos_common_support.py | 2 +- test/test_centos_fedora_common_support.py | 3 +-- test/test_fedora_support.py | 9 --------- 6 files changed, 3 insertions(+), 17 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index aebf5173..07166ec5 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -153,4 +153,4 @@ def mock_command_2(script, args, container): def run_script(Pihole, script): result = Pihole.run(script) assert result.rc == 0 - return result \ No newline at end of file + return result diff --git a/test/test_centos_7_support.py b/test/test_centos_7_support.py index 78cc6070..2f744ab4 100644 --- a/test/test_centos_7_support.py +++ b/test/test_centos_7_support.py @@ -1,8 +1,6 @@ -import pytest from .conftest import ( tick_box, info_box, - cross_box, mock_command, ) diff --git a/test/test_centos_8_support.py b/test/test_centos_8_support.py index 899cff2f..d3e83658 100644 --- a/test/test_centos_8_support.py +++ b/test/test_centos_8_support.py @@ -1,8 +1,6 @@ -import pytest from .conftest import ( tick_box, info_box, - cross_box, mock_command, ) diff --git a/test/test_centos_common_support.py b/test/test_centos_common_support.py index 4490f220..fdf43cba 100644 --- a/test/test_centos_common_support.py +++ b/test/test_centos_common_support.py @@ -117,4 +117,4 @@ def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole): assert remi_package.is_installed updated_php_package = Pihole.package('php') updated_php_version = updated_php_package.version.split('.')[0] - assert int(updated_php_version) == 7 \ No newline at end of file + assert int(updated_php_version) == 7 diff --git a/test/test_centos_fedora_common_support.py b/test/test_centos_fedora_common_support.py index 7338f0fc..21ae6d1d 100644 --- a/test/test_centos_fedora_common_support.py +++ b/test/test_centos_fedora_common_support.py @@ -1,7 +1,5 @@ -import pytest from .conftest import ( tick_box, - info_box, cross_box, mock_command, ) @@ -52,6 +50,7 @@ def test_selinux_permissive(Pihole): assert expected_stdout in check_selinux.stdout assert check_selinux.rc == 0 + def test_selinux_disabled(Pihole): ''' confirms installer continues when SELinux is Disabled diff --git a/test/test_fedora_support.py b/test/test_fedora_support.py index a5823883..473b2e96 100644 --- a/test/test_fedora_support.py +++ b/test/test_fedora_support.py @@ -1,12 +1,3 @@ -import pytest -from .conftest import ( - tick_box, - info_box, - cross_box, - mock_command, -) - - def test_epel_and_remi_not_installed_fedora(Pihole): ''' confirms installer does not attempt to install EPEL/REMI repositories From d0af1a950bd45ed4eeb3ed3b82d2624a4f7efc63 Mon Sep 17 00:00:00 2001 From: Reto Gantenbein Date: Tue, 1 Dec 2020 23:43:55 +0100 Subject: [PATCH 4/8] Ensure x86_64 processor architecture is listed as supported Signed-off-by: Reto Gantenbein --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 5c2b5f1c..e300c14a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -560,7 +560,7 @@ processor_check() { else # Check if the architecture is currently supported for FTL case "${PROCESSOR}" in - "amd64") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}" + "amd64" | "x86_64") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}" ;; "armv6l") log_write "${TICK} ${COL_GREEN}${PROCESSOR}${COL_NC}" ;; From 36937b19132df631220e4a5912f889e58a357cbc Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 2 Dec 2020 20:52:39 +0100 Subject: [PATCH 5/8] Strip such lines starting with a #. Do not silently truncate lines if they have a # somewhere in between (like server=127.0.0.1#5353) Signed-off-by: DL6ER --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 5c2b5f1c..30ca6031 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -977,7 +977,7 @@ make_array_from_file() { # Otherwise, read the file line by line while IFS= read -r line;do # Othwerise, strip out comments and blank lines - new_line=$(echo "${line}" | sed -e 's/#.*$//' -e '/^$/d') + new_line=$(echo "${line}" | sed -e 's/^\s*#.*$//' -e '/^$/d') # If the line still has content (a non-zero value) if [[ -n "${new_line}" ]]; then # Put it into the array From 61f13a334d2fb7ca81a3a47c7d9fc599a72d9164 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 2 Dec 2020 20:19:59 +0000 Subject: [PATCH 6/8] Don't delete an existing directory and clone our repo in its place. TODO: Something more robust Signed-off-by: Adam Warner --- automated install/basic-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index bab6471e..5470a9fb 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -528,8 +528,8 @@ make_repo() { printf " %b %s..." "${INFO}" "${str}" # If the directory exists, if [[ -d "${directory}" ]]; then - # delete everything in it so git can clone into it - rm -rf "${directory}" + # Return with a 1 to exit the installer. We don't want to overwrite what could already be here in case it is not ours + return 1 fi # Clone the repo and return the return code from this command git clone -q --depth 20 "${remoteRepo}" "${directory}" &> /dev/null || return $? From 641951b3a041a0a99c295fc977a1edef9fb87262 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 2 Dec 2020 20:35:40 +0000 Subject: [PATCH 7/8] add some meaningful outputSigned-off-by: Adam Warner --- automated install/basic-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 5470a9fb..9d5b4465 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -529,6 +529,8 @@ make_repo() { # If the directory exists, if [[ -d "${directory}" ]]; then # Return with a 1 to exit the installer. We don't want to overwrite what could already be here in case it is not ours + str="Unable to clone ${remoteRepo} into ${directory}" + printf "%b %b%s\\n" "${OVER}" "${CROSS}" "${str}" return 1 fi # Clone the repo and return the return code from this command From e47eb30a6e269895346dd4299591c930e631388f Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Wed, 2 Dec 2020 20:49:07 +0000 Subject: [PATCH 8/8] Update automated install/basic-install.sh Signed-off-by: Adam Warner --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 9d5b4465..45e96354 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -529,7 +529,7 @@ make_repo() { # If the directory exists, if [[ -d "${directory}" ]]; then # Return with a 1 to exit the installer. We don't want to overwrite what could already be here in case it is not ours - str="Unable to clone ${remoteRepo} into ${directory}" + str="Unable to clone ${remoteRepo} into ${directory} : Directory already exists" printf "%b %b%s\\n" "${OVER}" "${CROSS}" "${str}" return 1 fi