From 7dcca6f364c1f2155b2de81df6b3f4e379bbdcbb Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Mon, 25 Jan 2021 13:47:51 -0500 Subject: [PATCH] change when we detect os and wait_for_apt when installing sshpass --- setup/so-functions | 42 ++++++++++++++++++++++++------------------ setup/so-setup | 5 +++-- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index 1df065e71..5603e7c95 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -913,6 +913,29 @@ detect_os() { exit 1 fi + elif [ -f /etc/os-release ]; then + OS=ubuntu + if grep -q "UBUNTU_CODENAME=bionic" /etc/os-release; then + OSVER=bionic + elif grep -q "UBUNTU_CODENAME=xenial" /etc/os-release; then + OSVER=xenial + else + echo "We do not support your current version of Ubuntu." + exit 1 + fi + + else + echo "We were unable to determine if you are using a supported OS." + exit 1 + fi + + echo "Found OS: $OS $OSVER" >> "$setup_log" 2>&1 + +} + +installer_prereq_packages() { + + if [ "$OS" == centos ]; then # Print message to stdout so the user knows setup is doing something echo "Installing required packages to run installer..." # Install bind-utils so the host command exists @@ -937,17 +960,7 @@ detect_os() { logCmd "systemctl enable NetworkManager" logCmd "systemctl start NetworkManager" fi - elif [ -f /etc/os-release ]; then - OS=ubuntu - if grep -q "UBUNTU_CODENAME=bionic" /etc/os-release; then - OSVER=bionic - elif grep -q "UBUNTU_CODENAME=xenial" /etc/os-release; then - OSVER=xenial - else - echo "We do not support your current version of Ubuntu." - exit 1 - fi - + elif [ "$OS" == ubuntu ]; then # Print message to stdout so the user knows setup is doing something echo "Installing required packages to run installer..." # Install network manager so we can do interface stuff @@ -960,13 +973,6 @@ detect_os() { fi if wait_for_apt; then apt-get install -y bc curl >> "$setup_log" 2>&1; else exit 1; fi - else - echo "We were unable to determine if you are using a supported OS." - exit 1 - fi - - echo "Found OS: $OS $OSVER" >> "$setup_log" 2>&1 - } disable_auto_start() { diff --git a/setup/so-setup b/setup/so-setup index 30896729f..da885c6b3 100755 --- a/setup/so-setup +++ b/setup/so-setup @@ -104,7 +104,7 @@ function progress() { fi } -detect_os && detect_cloud +detect_os if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then echo "Preselecting variable values based on automated setup: $automation" >> $setup_log 2>&1 @@ -130,7 +130,7 @@ if [[ -f automation/$automation && $(basename $automation) == $automation ]]; th if [[ ! $is_iso ]]; then echo "Installing sshpass for automated testing." >> $setup_log 2>&1 if [ "$OS" == ubuntu ]; then - apt-get -y install sshpass >> $setup_log 2>&1 + if wait_for_apt; then apt-get -y install sshpass >> $setup_log 2>&1 else yum -y install sshpass >> $setup_log 2>&1 fi @@ -154,6 +154,7 @@ set_ssh_cmds $automated local_sbin="$(pwd)/../salt/common/tools/sbin" export PATH=$PATH:$local_sbin +installer_prereq_packages && detect_cloud set_network_dev_status_list if [ "$OS" == ubuntu ]; then