From 043f2df7e3d8e3fe121b8598adc4d33e03ccc330 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Sat, 18 Apr 2020 18:26:27 -0400 Subject: [PATCH] [refactor] Set enabled components in whiptail function --- setup/so-functions | 16 ---------------- setup/so-setup | 2 -- setup/so-whiptail | 21 ++++++++++++++++++++- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index fc925e0a1..b4d52d3a3 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -983,22 +983,6 @@ patch_schedule_os_new() { } -process_components() { - CLEAN=${COMPONENTS//\"} - GRAFANA=0 - OSQUERY=0 - WAZUH=0 - THEHIVE=0 - PLAYBOOK=0 - STRELKA=0 - - IFS=$' ' - for item in $(echo "$CLEAN"); do - let $item=1 - done - unset IFS -} - reserve_group_ids() { # This is a hack to fix CentOS from taking group IDs that we need diff --git a/setup/so-setup b/setup/so-setup index a875d8748..cb06a1c07 100755 --- a/setup/so-setup +++ b/setup/so-setup @@ -279,7 +279,6 @@ if (whiptail_you_sure) ; then # Find out how to handle updates whiptail_master_updates whiptail_enable_components - process_components # Do Advacned Setup if they chose it if [ "$MASTERADV" == 'ADVANCED' ]; then @@ -561,7 +560,6 @@ if (whiptail_you_sure) ; then NIDS=Suricata BROVERSION=ZEEK CURCLOSEDAYS=30 - process_components if [ $INSTALLTYPE == 'MASTERSEARCH' ]; then # Find out how to handle updates whiptail_master_updates diff --git a/setup/so-whiptail b/setup/so-whiptail index 47aa19ba8..63dc3944e 100755 --- a/setup/so-whiptail +++ b/setup/so-whiptail @@ -268,6 +268,20 @@ whiptail_enable_components() { "THEHIVE" "Enable TheHive" ON \ "PLAYBOOK" "Enable Playbook" ON \ "STRELKA" "Enable Strelka" ON 3>&1 1>&2 2>&3 ) + + # Init the environment variables + GRAFANA=0 + OSQUERY=0 + WAZUH=0 + THEHIVE=0 + PLAYBOOK=0 + STRELKA=0 + + # Set any variables to 1 if they exist in COMPONENTS + for component in "${COMPONENTS[@]}"; do + component="$(echo -e "$component" | tr -d '"')" + eval "$component"="1" + done local exitstatus=$? whiptail_check_exitstatus $exitstatus @@ -659,9 +673,12 @@ whiptail_node_ls_input_batch_count() { } + +#TODO: helper function to display error message or exit if batch mode + whiptail_passwords_dont_match() { - [ -z "$QUIET" ] && return + # exit_if_batch "Error string" Error code (int) whiptail --title "Security Onion Setup" --msgbox "Passwords don't match. Please re-enter." 8 75 @@ -948,6 +965,8 @@ whiptail_you_sure() { [ -z "$QUIET" ] && return + + echo "whiptail_you_sure called" >> $SETUPLOG 2>&1 whiptail --title "Security Onion Setup" --yesno "Are you sure you want to install Security Onion over the internet?" 8 75