mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #7749 from Security-Onion-Solutions/issue/7113
ensure we can grab management ip and display whiptail if we cant
This commit is contained in:
@@ -2438,8 +2438,28 @@ set_network_dev_status_list() {
|
||||
}
|
||||
|
||||
set_main_ip() {
|
||||
local count=0
|
||||
local progress='.'
|
||||
local c=0
|
||||
local m=3.3
|
||||
local max_attempts=30
|
||||
echo "Gathering the management IP. "
|
||||
while ! valid_ip4 "$MAINIP" || ! valid_ip4 "$MNIC_IP"; do
|
||||
MAINIP=$(ip route get 1 | awk '{print $7;exit}')
|
||||
MNIC_IP=$(ip a s "$MNIC" | grep -oE 'inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | cut -d' ' -f2)
|
||||
((count=count+1))
|
||||
p=$(awk -vp=$m -vq=$count 'BEGIN{printf "%.0f" ,p * q}')
|
||||
printf "%-*s" $((count+1)) '[' | tr ' ' '#'
|
||||
printf "%*s%3d%%\r" $((max_attempts-count)) "]" "$p"
|
||||
if [ $count = $max_attempts ]; then
|
||||
echo "ERROR: Could not determine MAINIP or MNIC_IP." >> "$setup_log" 2>&1
|
||||
echo "MAINIP=$MAINIP" >> "$setup_log" 2>&1
|
||||
echo "MNIC_IP=$MNIC_IP" >> "$setup_log" 2>&1
|
||||
whiptail_error_message "The management IP could not be determined. Please check the log at /root/sosetup.log and verify the network configuration. Press OK to exit."
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
# Add /usr/sbin to everyone's path
|
||||
|
||||
@@ -260,7 +260,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
printf '%s\n' \
|
||||
"MNIC=$MNIC" \
|
||||
"HOSTNAME=$HOSTNAME" > "$net_init_file"
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
set_main_ip
|
||||
compare_main_nic_ip
|
||||
|
||||
fi
|
||||
@@ -275,7 +275,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
printf '%s\n' \
|
||||
"MNIC=$MNIC" \
|
||||
"HOSTNAME=$HOSTNAME" > "$net_init_file"
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
set_main_ip
|
||||
compare_main_nic_ip
|
||||
whiptail_net_setup_complete
|
||||
else
|
||||
@@ -375,7 +375,7 @@ if ! [[ -f $install_opt_file ]]; then
|
||||
network_init
|
||||
fi
|
||||
|
||||
set_main_ip >> $setup_log 2>&1
|
||||
set_main_ip
|
||||
compare_main_nic_ip
|
||||
|
||||
if [[ $is_minion ]]; then
|
||||
|
||||
@@ -1501,6 +1501,14 @@ whiptail_oinkcode() {
|
||||
#TODO: helper function to display error message or exit if batch mode
|
||||
# exit_if_batch <"Error string"> <Error code (int)>
|
||||
|
||||
whiptail_error_message() {
|
||||
|
||||
local error_message=$1 # message to be displayed
|
||||
|
||||
whiptail --title "$whiptail_title" --msgbox "$error_message" 10 75
|
||||
|
||||
}
|
||||
|
||||
whiptail_passwords_dont_match() {
|
||||
|
||||
whiptail --title "$whiptail_title" --msgbox "Passwords don't match. Please re-enter." 8 75
|
||||
|
||||
Reference in New Issue
Block a user