[fix] Test if QUIET var is set, and convert whiptail output to arrays

Also rewrite filter_unused_nics so it is the only source for list of nics
This commit is contained in:
William Wernert
2020-04-22 13:12:57 -04:00
parent 0250bf026a
commit 3f264163d4
2 changed files with 181 additions and 163 deletions

View File

@@ -5,19 +5,27 @@ source './so-variables'
# Helper functions
filter_unused_nics() {
# Set the main NIC as the default grep search string
local grep_string="$MNIC"
if [[ $MNIC ]]; then local grep_string="$MNIC\|bond0"; else local grep_string="bond0"; fi
# If we call this function and NICs have already been assigned to the bond interface then add them to the grep search string
if [[ $BNICS ]]; then
grep_string="$grep_string"
for BONDNIC in "${BNICS[@]}"; do
grep_string="$grep_string\|$BONDNIC"
done
fi
# Finally, set filtered_nics to any NICs we aren't using (and ignore interfaces that aren't of use)
filtered_nics=$(ip link | grep -vwe "$grep_string" | awk -F: '$0 !~ "lo|vir|veth|br|docker|wl|^[^0-9]"{print $2}')
export filtered_nics
filtered_nics=$(ip link | grep -vwe "$grep_string" | awk -F: '$0 !~ "lo|vir|veth|br|docker|wl|^[^0-9]"{print $2}' | sed 's/ //')
readarray -t filtered_nics <<< "$filtered_nics"
nic_list=()
for nic in "${filtered_nics[@]}"; do
nic_list+=("$nic" "" "OFF")
done
export nic_list
}
calculate_useable_cores() {