From c97798b57db036272473f5ea8cd246ab111bd53f Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 1 Jul 2020 09:43:39 -0400 Subject: [PATCH] [feat] Add check to see if bond nics are managed by Network Manager --- setup/so-variables | 6 +++++- setup/so-whiptail | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/setup/so-variables b/setup/so-variables index 4e08b2fef..bd5f8869d 100644 --- a/setup/so-variables +++ b/setup/so-variables @@ -42,4 +42,8 @@ export default_salt_dir=/opt/so/saltstack/default export local_salt_dir=/opt/so/saltstack/local -export SCRIPTDIR=$(cd `dirname $0` && pwd) +SCRIPTDIR=$(cd "$(dirname "$0")" && pwd) +export SCRIPTDIR + +readarray -t nmcli_dev_status_list <<< "$(nmcli -t -f DEVICE,STATE -c no dev status)" +export nmcli_dev_status_list diff --git a/setup/so-whiptail b/setup/so-whiptail index de27b691b..d047f3253 100755 --- a/setup/so-whiptail +++ b/setup/so-whiptail @@ -92,6 +92,20 @@ whiptail_bond_nics() { BNICS=$(echo "$BNICS" | tr -d '"') IFS=' ' read -ra BNICS <<< "$BNICS" + + local unmanaged_bond=0 + for bond_nic in "${BNICS[@]}"; do + if [[ ! "${nmcli_dev_status_list}" =~ $bond_nic\:unmanaged ]]; then + unmanaged_bond=1 + fi + if [[ "$unmanaged_bond" == 1 ]]; then + whiptail \ + --title "Security Onion Setup" \ + --msgbox "$bond_nic is unmanaged by Network Manager. Please remove it from other network management tools then re-run setup." \ + 8 75 + exit + fi + done } whiptail_bond_nics_mtu() {