Add initial analyst install code

This commit is contained in:
Mike Reeves
2022-03-29 12:43:20 -04:00
parent 990470a765
commit 80af497f95
3 changed files with 35 additions and 30 deletions

View File

@@ -169,6 +169,13 @@ calculate_useable_cores() {
export lb_procs export lb_procs
} }
catch() {
info "Fatal error occurred at $1 in so-setup, failing setup."
grep --color=never "ERROR" "$setup_log" > "$error_log"
whiptail_setup_failed
exit 1
}
check_admin_pass() { check_admin_pass() {
check_pass_match "$ADMINPASS1" "$ADMINPASS2" "APMATCH" check_pass_match "$ADMINPASS1" "$ADMINPASS2" "APMATCH"
} }
@@ -1780,13 +1787,14 @@ manager_global() {
" rules: 1" >> "$global_pillar" " rules: 1" >> "$global_pillar"
if [[ $is_airgap ]]; then if [[ $is_airgap ]]; then
printf '%s\n'\ printf '%s\n'\
" repos:"\'$PATCHSCHEDULENAME' " repos: '$PATCHSCHEDULENAME'"\
" - 'https://$HOSTNAME/repo/rules/strelka'" >> "$global_pillar" " - 'https://$HOSTNAME/repo/rules/strelka'" >> "$global_pillar"
else else
printf '%s\n'\ printf '%s\n'\
" repos:"\ " repos:"\
" - 'https://github.com/Neo23x0/signature-base'" >> "$global_pillar" " - 'https://github.com/Neo23x0/signature-base'" >> "$global_pillar"
fi fi
printf '%s\n'\ printf '%s\n'\
"curator:"\ "curator:"\
" hot_warm: False"\ " hot_warm: False"\
@@ -1806,7 +1814,7 @@ manager_global() {
printf '%s\n'\ printf '%s\n'\
" replicas: 0"\ " replicas: 0"\
" discovery_nodes: 1"\'$PATCHSCHEDULENAME' " discovery_nodes: 1"\
" hot_warm_enabled: False"\ " hot_warm_enabled: False"\
" cluster_routing_allocation_disk.threshold_enabled: true"\ " cluster_routing_allocation_disk.threshold_enabled: true"\
" cluster_routing_allocation_disk_watermark_low: '95%'"\ " cluster_routing_allocation_disk_watermark_low: '95%'"\
@@ -1826,7 +1834,8 @@ manager_global() {
" index_template:"\ " index_template:"\
" template:"\ " template:"\
" settings:"\ " settings:"\
" index:"\'$PATCHSCHEDULENAME' " index:"\
" number_of_shards: 1"\
" warm: 7"\ " warm: 7"\
" close: 30"\ " close: 30"\
" delete: 365"\ " delete: 365"\
@@ -2058,6 +2067,16 @@ print_salt_state_apply() {
echo "Applying $state Salt state" echo "Applying $state Salt state"
} }
progress() {
local msg=${1:-'Please wait while installing...'}
if [ $automated == no ]; then
whiptail --title "$whiptail_title" --gauge "$msg" 6 70 0 # append to text
else
cat >> $setup_log 2>&1
fi
}
proxy_validate() { proxy_validate() {
echo "Testing proxy..." echo "Testing proxy..."
local test_url="https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS" local test_url="https://raw.githubusercontent.com/Security-Onion-Solutions/securityonion/master/KEYS"

View File

@@ -99,6 +99,9 @@ if [[ $is_analyst ]]; then
exit 0 exit 0
# If you got this far then you want to join the grid
is_minion=true
fi fi
@@ -128,23 +131,9 @@ fi
# Set up handler for setup to exit early (use `kill -SIGUSR1 "$setup_proc"; exit 1` in child scripts) # Set up handler for setup to exit early (use `kill -SIGUSR1 "$setup_proc"; exit 1` in child scripts)
trap 'catch $LINENO' SIGUSR1 trap 'catch $LINENO' SIGUSR1
setup_proc="$$" setup_proc="$$"
catch() { catch
info "Fatal error occurred at $1 in so-setup, failing setup."
grep --color=never "ERROR" "$setup_log" > "$error_log"
whiptail_setup_failed
exit 1
}
automated=no automated=no
progress() { progress
local msg=${1:-'Please wait while installing...'}
if [ $automated == no ]; then
whiptail --title "$whiptail_title" --gauge "$msg" 6 70 0 # append to text
else
cat >> $setup_log 2>&1
fi
}
if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then
echo "Preselecting variable values based on automated setup: $automation" >> $setup_log 2>&1 echo "Preselecting variable values based on automated setup: $automation" >> $setup_log 2>&1
@@ -178,11 +167,11 @@ if [[ -f automation/$automation && $(basename $automation) == $automation ]]; th
fi fi
case "$setup_type" in case "$setup_type" in
iso | network) # Accepted values iso | network | analyst) # Accepted values
echo "Beginning Security Onion $setup_type install" >> $setup_log 2>&1 echo "Beginning Security Onion $setup_type install" >> $setup_log 2>&1
;; ;;
*) *)
echo "Invalid install type, must be 'iso' or 'network'" | tee -a $setup_log echo "Invalid install type, must be 'iso', 'network' or 'analyst'." | tee -a $setup_log
exit 1 exit 1
;; ;;
esac esac
@@ -291,7 +280,7 @@ elif [ "$install_type" = 'RECEIVER' ]; then
is_receiver=true is_receiver=true
elif [ "$install_type" = 'ANALYST' ]; then elif [ "$install_type" = 'ANALYST' ]; then
cd .. || exit 255 cd .. || exit 255
exec bash so-analyst-install exec bash so-setup analyst
fi fi
if [[ $is_manager || $is_import ]]; then if [[ $is_manager || $is_import ]]; then
@@ -311,7 +300,7 @@ if ! [[ -f $install_opt_file ]]; then
check_requirements "dist" "idh" check_requirements "dist" "idh"
elif [[ $is_sensor && ! $is_eval ]]; then elif [[ $is_sensor && ! $is_eval ]]; then
check_requirements "dist" "sensor" check_requirements "dist" "sensor"
elif [[ $is_distmanager || $is_minion ]] && [[ ! $is_import ]]; then elif [[ $is_distmanager || $is_minion ]] && [[ ! ( $is_import || $is_analyst ) ]]; then
check_requirements "dist" check_requirements "dist"
elif [[ $is_import ]]; then elif [[ $is_import ]]; then
check_requirements "import" check_requirements "import"
@@ -342,9 +331,6 @@ if ! [[ -f $install_opt_file ]]; then
if [[ $is_minion ]]; then if [[ $is_minion ]]; then
collect_mngr_hostname collect_mngr_hostname
add_mngr_ip_to_hosts add_mngr_ip_to_hosts
fi
if [[ $is_minion ]]; then
whiptail_ssh_key_copy_notice whiptail_ssh_key_copy_notice
copy_ssh_key >> $setup_log 2>&1 copy_ssh_key >> $setup_log 2>&1
fi fi
@@ -355,7 +341,7 @@ if ! [[ -f $install_opt_file ]]; then
if [[ "$INTERWEBS" == 'AIRGAP' ]]; then if [[ "$INTERWEBS" == 'AIRGAP' ]]; then
is_airgap=true is_airgap=true
fi fi
elif [[ $is_minion && $is_iso ]]; then elif [[ $is_minion && ( $is_iso || $is_analyst ) ]]; then
$sshcmd -i /root/.ssh/so.key soremote@"$MSRV" [[ -f /etc/yum.repos.d/airgap_repo.repo ]] >> $setup_log 2>&1 $sshcmd -i /root/.ssh/so.key soremote@"$MSRV" [[ -f /etc/yum.repos.d/airgap_repo.repo ]] >> $setup_log 2>&1
airgap_check=$? airgap_check=$?
[[ $airgap_check == 0 ]] && is_airgap=true >> $setup_log 2>&1 [[ $airgap_check == 0 ]] && is_airgap=true >> $setup_log 2>&1
@@ -584,7 +570,7 @@ if [[ $is_sensor && ! $is_eval ]]; then
fi fi
fi fi
[[ $is_iso ]] && collect_ntp_servers [[ ( $is_iso || $is_analyst ) ]] && collect_ntp_servers
if [[ ($is_node || $is_receiver) && ! $is_eval ]]; then if [[ ($is_node || $is_receiver) && ! $is_eval ]]; then
whiptail_node_advanced whiptail_node_advanced

View File

@@ -39,9 +39,9 @@ whiptail_analyst_install() {
read -r -d '' message <<- EOM read -r -d '' message <<- EOM
Welcome to the Security Onion Anaylst Workstation install! Welcome to the Security Onion Analyst Workstation install!
You can choose to use join this workstation to an existing grid for managemnt or make it standalone. You can choose to join this workstation to an existing grid for managemnt or make it standalone.
EOM EOM
whiptail --title "$whiptail_title" \ whiptail --title "$whiptail_title" \