From fbec401145bf89497e3615ca0ff726a245520d57 Mon Sep 17 00:00:00 2001 From: Mike Reeves Date: Tue, 5 Jun 2018 13:24:14 -0400 Subject: [PATCH] Setup Script - Add Hostname Check --- so-setup-network.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/so-setup-network.sh b/so-setup-network.sh index 501b2ac53..ea11145c6 100644 --- a/so-setup-network.sh +++ b/so-setup-network.sh @@ -53,6 +53,15 @@ accept_salt_key_remote() { } +add_master_hostfile() { + # Pop up an input to get the IP address + local MSRVIP=$(whiptail --title "Security Onion Setup" --inputbox \ + "Enter your Master Server IP Address" 10 60 X.X.X.X 3>&1 1>&2 2>&3) + + # Add the master to the host file if it doesn't resolve + echo "$MSRV $MSRVIP" >> /etc/hosts +} + add_socore_user_master() { if [ $OS == 'centos' ]; then local ADDUSER=adduser @@ -680,7 +689,15 @@ whiptail_make_changes() { whiptail_management_server() { MSRV=$(whiptail --title "Security Onion Setup" --inputbox \ - "Enter your Master Server Name or IP Address" 10 60 XXXX 3>&1 1>&2 2>&3) + "Enter your Master Server HOSTNAME" 10 60 XXXX 3>&1 1>&2 2>&3) + + # See if it resolves. Otherwise prompt to add to host file + TESTHOST=$(host $MSRV) + + if [[ $TESTHOST = *"not found"* ]]; then + add_master_hostfile + fi + local exitstatus=$? whiptail_check_exitstatus $exitstatus