change whiptail selections from radiolist to menu where appropriate

This commit is contained in:
Doug Burks
2023-02-06 11:52:42 -05:00
parent 22a18d8855
commit cd38ecb300
2 changed files with 45 additions and 41 deletions

View File

@@ -1152,22 +1152,26 @@ filter_unused_nics() {
readarray -t filtered_nics <<< "$filtered_nics" readarray -t filtered_nics <<< "$filtered_nics"
nic_list=() nic_list=()
nic_list_management=()
for nic in "${filtered_nics[@]}"; do for nic in "${filtered_nics[@]}"; do
local nic_mac=$(cat "/sys/class/net/${nic}/address" 2>/dev/null) local nic_mac=$(cat "/sys/class/net/${nic}/address" 2>/dev/null)
case $(cat "/sys/class/net/${nic}/carrier" 2>/dev/null) in case $(cat "/sys/class/net/${nic}/carrier" 2>/dev/null) in
1) 1)
nic_list+=("$nic" "$nic_mac Link UP " "OFF") nic_list+=("$nic" "$nic_mac Link UP " "OFF")
nic_list_management+=("$nic" "$nic_mac Link UP " )
;; ;;
0) 0)
nic_list+=("$nic" "$nic_mac Link DOWN " "OFF") nic_list+=("$nic" "$nic_mac Link DOWN " "OFF")
nic_list_management+=("$nic" "$nic_mac Link DOWN " )
;; ;;
*) *)
nic_list+=("$nic" "$nic_mac Link UNKNOWN " "OFF") nic_list+=("$nic" "$nic_mac Link UNKNOWN " "OFF")
nic_list_management+=("$nic" "$nic_mac Link UNKNOWN " )
;; ;;
esac esac
done done
export nic_list export nic_list nic_list_management
} }
# Generate Firewall Templates # Generate Firewall Templates

View File

@@ -262,10 +262,10 @@ whiptail_dhcp_or_static() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
address_type=$(whiptail --title "$whiptail_title" --radiolist \ address_type=$(whiptail --title "$whiptail_title" --menu \
"Choose how to set up your management interface:" 20 78 4 \ "Choose how to set up your management interface:" 20 78 4 \
"STATIC" "Set a static IPv4 address" ON \ "STATIC" "Set a static IPv4 address" \
"DHCP" "Use DHCP to configure the Management Interface" OFF 3>&1 1>&2 2>&3 ) "DHCP" "Use DHCP to configure the Management Interface" 3>&1 1>&2 2>&3 )
local exitstatus=$? local exitstatus=$?
whiptail_check_exitstatus $exitstatus whiptail_check_exitstatus $exitstatus
@@ -471,13 +471,13 @@ whiptail_install_type() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
# What kind of install are we doing? # What kind of install are we doing?
install_type=$(whiptail --title "$whiptail_title" --radiolist \ install_type=$(whiptail --title "$whiptail_title" --menu \
"What kind of installation would you like to do?\n\nFor more information, please see:\n$DOC_BASE_URL/architecture.html" 18 65 5 \ "What kind of installation would you like to do?\n\nFor more information, please see:\n$DOC_BASE_URL/architecture.html" 18 65 5 \
"IMPORT" "Import PCAP or log files " ON \ "IMPORT" "Import PCAP or log files " \
"EVAL" "Evaluation mode (not for production) " OFF \ "EVAL" "Evaluation mode (not for production) " \
"STANDALONE" "Standalone production install " OFF \ "STANDALONE" "Standalone production install " \
"DISTRIBUTED" "Distributed install submenu " OFF \ "DISTRIBUTED" "Distributed install submenu " \
"OTHER" "Other install types" OFF \ "OTHER" "Other install types" \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3
) )
@@ -503,8 +503,8 @@ whiptail_install_type_dist() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
dist_option=$(whiptail --title "$whiptail_title" --menu "Do you want to start a new deployment or join this box to \nan existing deployment?" 11 75 2 \ dist_option=$(whiptail --title "$whiptail_title" --menu "Do you want to start a new deployment or join this box to \nan existing deployment?" 11 75 2 \
"Existing Deployment " "Join to an existing Security Onion deployment " \
"New Deployment " "Create a new Security Onion deployment" \ "New Deployment " "Create a new Security Onion deployment" \
"Existing Deployment " "Join to an existing Security Onion deployment " \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3
) )
local exitstatus=$? local exitstatus=$?
@@ -525,9 +525,9 @@ whiptail_install_type_dist_new() {
Note: MANAGER is the recommended option for most users. MANAGERSEARCH should only be used in very specific situations. Note: MANAGER is the recommended option for most users. MANAGERSEARCH should only be used in very specific situations.
EOM EOM
install_type=$(whiptail --title "$whiptail_title" --radiolist "$mngr_msg" 15 75 2 \ install_type=$(whiptail --title "$whiptail_title" --menu "$mngr_msg" 20 75 2 \
"MANAGER" "New grid, requires separate search node(s) " ON \ "MANAGER" "New grid, requires separate search node(s) " \
"MANAGERSEARCH" "New grid, separate search node(s) are optional " OFF \ "MANAGERSEARCH" "New grid, separate search node(s) are optional " \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3
) )
@@ -545,18 +545,18 @@ whiptail_install_type_dist_existing() {
Note: Heavy nodes (HEAVYNODE) are NOT recommended for most users. Note: Heavy nodes (HEAVYNODE) are NOT recommended for most users.
EOM EOM
install_type=$(whiptail --title "$whiptail_title" --radiolist "$node_msg" 19 58 6 \ install_type=$(whiptail --title "$whiptail_title" --menu "$node_msg" 19 75 6 \
"SENSOR" "Create a forward only sensor " ON \ "SENSOR" "Create a forward only sensor " \
"SEARCHNODE" "Add a search node with parsing " OFF \ "SEARCHNODE" "Add a search node with parsing " \
"FLEET" "Dedicated Fleet Osquery Node " OFF \ "FLEET" "Dedicated Fleet Osquery Node " \
"HEAVYNODE" "Sensor + Search Node " OFF \ "HEAVYNODE" "Sensor + Search Node " \
"IDH" "Intrusion Detection Honeypot Node " OFF \ "IDH" "Intrusion Detection Honeypot Node " \
"RECEIVER" "Receiver Node " OFF \ "RECEIVER" "Receiver Node " \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3
# "HOTNODE" "Add Hot Node (Uses Elastic Clustering)" OFF \ # TODO # "HOTNODE" "Add Hot Node (Uses Elastic Clustering)" \ # TODO
# "WARMNODE" "Add Warm Node to existing Hot or Search node" OFF \ # TODO # "WARMNODE" "Add Warm Node to existing Hot or Search node" \ # TODO
# "WAZUH" "Stand Alone Wazuh Server" OFF \ # TODO # "WAZUH" "Stand Alone Wazuh Server" \ # TODO
# "STRELKA" "Stand Alone Strelka Node" OFF \ # TODO # "STRELKA" "Stand Alone Strelka Node" \ # TODO
) )
if [ "$install_type" = 'EVAL' ]; then if [ "$install_type" = 'EVAL' ]; then
is_eval=true is_eval=true
@@ -597,10 +597,10 @@ whiptail_install_type_other() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
install_type=$(whiptail --title "$whiptail_title" --radiolist \ install_type=$(whiptail --title "$whiptail_title" --menu \
"Choose node type:" 9 65 2 \ "Choose node type:" 10 65 2 \
"ANALYST" "Setup will run 'so-setup analyst' " ON \ "ANALYST" "Setup will run 'so-setup analyst' " \
"HELIXSENSOR" "Create a Helix sensor " OFF \ "HELIXSENSOR" "Create a Helix sensor " \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3
) )
@@ -788,13 +788,13 @@ whiptail_management_nic() {
filter_unused_nics filter_unused_nics
MNIC=$(whiptail --title "$whiptail_title" --radiolist "Please select the NIC you would like to use for management.\n\nUse the arrow keys to move around and the space bar to select." 22 75 12 "${nic_list[@]}" 3>&1 1>&2 2>&3 ) MNIC=$(whiptail --title "$whiptail_title" --menu "Please select the NIC you would like to use for management.\n\nUse the arrow keys to move around and the Enter key to select." 20 75 12 "${nic_list_management[@]}" 3>&1 1>&2 2>&3 )
local exitstatus=$? local exitstatus=$?
whiptail_check_exitstatus $exitstatus whiptail_check_exitstatus $exitstatus
while [ -z "$MNIC" ] while [ -z "$MNIC" ]
do do
MNIC=$(whiptail --title "$whiptail_title" --radiolist "Please select the NIC you would like to use for management.\n\nUse the arrow keys to move around and the space bar to select." 22 75 12 "${nic_list[@]}" 3>&1 1>&2 2>&3 ) MNIC=$(whiptail --title "$whiptail_title" --menu "Please select the NIC you would like to use for management.\n\nUse the arrow keys to move around and the Enter key to select." 22 75 12 "${nic_list_management[@]}" 3>&1 1>&2 2>&3 )
local exitstatus=$? local exitstatus=$?
whiptail_check_exitstatus $exitstatus whiptail_check_exitstatus $exitstatus
done done
@@ -878,10 +878,10 @@ whiptail_manager_adv() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
MANAGERADV=$(whiptail --title "$whiptail_title" --radiolist \ MANAGERADV=$(whiptail --title "$whiptail_title" --menu \
"Choose which type of manager to install:" 20 75 4 \ "Choose which type of manager to install:" 20 75 4 \
"BASIC" "Install manager with recommended settings" ON \ "BASIC" "Install manager with recommended settings" \
"ADVANCED" "Do additional configuration to the manager" OFF 3>&1 1>&2 2>&3 ) "ADVANCED" "Do additional configuration to the manager" 3>&1 1>&2 2>&3 )
local exitstatus=$? local exitstatus=$?
whiptail_check_exitstatus $exitstatus whiptail_check_exitstatus $exitstatus
@@ -1121,10 +1121,10 @@ whiptail_sensor_config() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
NSMSETUP=$(whiptail --title "$whiptail_title" --radiolist \ NSMSETUP=$(whiptail --title "$whiptail_title" --menu \
"What type of configuration would you like to use?" 20 75 4 \ "What type of configuration would you like to use?" 20 75 4 \
"BASIC" "Install NSM components with recommended settings" ON \ "BASIC" "Install NSM components with recommended settings" \
"ADVANCED" "Configure each component individually" OFF 3>&1 1>&2 2>&3 ) "ADVANCED" "Configure each component individually" 3>&1 1>&2 2>&3 )
local exitstatus=$? local exitstatus=$?
whiptail_check_exitstatus $exitstatus whiptail_check_exitstatus $exitstatus
@@ -1189,11 +1189,11 @@ whiptail_set_redirect() {
[ -n "$TESTING" ] && return [ -n "$TESTING" ] && return
local options=() local options=()
options+=( "IP" "Use IP address to access the web interface" ON ) options+=( "IP" "Use IP address to access the web interface" )
[[ $no_use_hostname != true ]] && options+=( "HOSTNAME" "Use hostname to access the web interface" OFF ) [[ $no_use_hostname != true ]] && options+=( "HOSTNAME" "Use hostname to access the web interface" )
options+=("OTHER" "Use a different name like a FQDN or Load Balancer" OFF) options+=("OTHER" "Use a different name like a FQDN or Load Balancer" )
REDIRECTINFO=$(whiptail --title "$whiptail_title" --radiolist \ REDIRECTINFO=$(whiptail --title "$whiptail_title" --menu \
"How would you like to access the web interface?\n\nWhatever you choose here will be the only way that you can access the web interface.\n\nIf you choose something other than IP address, then you'll need to ensure that you can resolve the name via DNS or hosts entry. If you are unsure, please select IP." 20 75 4 \ "How would you like to access the web interface?\n\nWhatever you choose here will be the only way that you can access the web interface.\n\nIf you choose something other than IP address, then you'll need to ensure that you can resolve the name via DNS or hosts entry. If you are unsure, please select IP." 20 75 4 \
"${options[@]}" \ "${options[@]}" \
3>&1 1>&2 2>&3 3>&1 1>&2 2>&3