mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
refactor automated testing inputs due to streamlined setup process
This commit is contained in:
@@ -322,7 +322,7 @@ collect_hostname() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
collect_hostname_validate() {
|
collect_hostname_validate() {
|
||||||
if [[ $automated == no ]] && [[ "$HOSTNAME" == *'localhost'* ]]; then HOSTNAME=securityonion; fi
|
if [[ -z "$TESTING" ]] && [[ "$HOSTNAME" == *'localhost'* ]]; then HOSTNAME=securityonion; fi
|
||||||
|
|
||||||
whiptail_set_hostname "$HOSTNAME"
|
whiptail_set_hostname "$HOSTNAME"
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,10 @@ source ./so-variables
|
|||||||
|
|
||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
setup_type=$1
|
setup_type=$1
|
||||||
automation=$2
|
test_profile=$2
|
||||||
|
|
||||||
WHATWOULDYOUSAYYAHDOHERE=setup
|
WHATWOULDYOUSAYYAHDOHERE=setup
|
||||||
|
|
||||||
# This is for automation
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
arg="$1"
|
arg="$1"
|
||||||
shift
|
shift
|
||||||
@@ -49,12 +49,8 @@ while [[ $# -gt 0 ]]; do
|
|||||||
export TURBO="http://${arg#*=}";;
|
export TURBO="http://${arg#*=}";;
|
||||||
"--proxy="* )
|
"--proxy="* )
|
||||||
export {http,https,ftp,rsync,all}_proxy="${arg#*=}";;
|
export {http,https,ftp,rsync,all}_proxy="${arg#*=}";;
|
||||||
"--allow-role="* )
|
|
||||||
export ALLOW_ROLE="${arg#*=}";;
|
|
||||||
"--allow-cidr="* )
|
"--allow-cidr="* )
|
||||||
export ALLOW_CIDR="${arg#*=}";;
|
export ALLOW_CIDR="${arg#*=}";;
|
||||||
"--skip-reboot" )
|
|
||||||
export SKIP_REBOOT=1;;
|
|
||||||
* )
|
* )
|
||||||
if [[ "$arg" == "--"* ]]; then
|
if [[ "$arg" == "--"* ]]; then
|
||||||
echo "Invalid option"
|
echo "Invalid option"
|
||||||
@@ -166,41 +162,47 @@ catch() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
automated=no
|
|
||||||
|
|
||||||
# Add the progress function for manager node type installs
|
# Add the progress function for manager node type installs
|
||||||
progress() {
|
progress() {
|
||||||
local msg=${1:-'Please wait while installing...'}
|
local msg=${1:-'Please wait while installing...'}
|
||||||
|
|
||||||
if [ $automated == no ]; then
|
if [ -z "$TESTING" ]; then
|
||||||
whiptail --title "$whiptail_title" --gauge "$msg" 6 70 0 # append to text
|
whiptail --title "$whiptail_title" --gauge "$msg" 6 70 0 # append to text
|
||||||
else
|
else
|
||||||
cat >> $setup_log 2>&1
|
cat >> $setup_log 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# If using automation let's do automation things.
|
if [ -n "$test_profile" ]; then
|
||||||
if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then
|
install_type="$(echo $test_profile |awk -F- '{print $1}')"
|
||||||
info "Preselecting variable values based on automated setup: $automation"
|
info "Activating test profile: $test_profile"
|
||||||
source automation/$automation
|
|
||||||
automated=yes
|
|
||||||
|
|
||||||
attempt=1
|
# The below settings are hardcoded purely for automated testing purposes.
|
||||||
attempts=60
|
TESTING=true
|
||||||
ip a | grep "$MNIC:" | grep "state UP" >> $setup_log 2>&1
|
MSRV=manager
|
||||||
while [ $? -ne 0 ]; do
|
if [ "$test_profile" =~ *"-net" ]; then
|
||||||
logCmd "ip a"
|
address_type=DHCP
|
||||||
if [ $attempt -gt $attempts ]; then
|
MSRVIP=10.66.166.72
|
||||||
error "Network unavailable - setup cannot continue"
|
elif [ "$test_profile" =~ *"-cloud" ]; then
|
||||||
exit 1
|
MSRVIP=10.99.1.20
|
||||||
fi
|
elif [ "$test_profile" =~ *"-iso" ]; then
|
||||||
info "Waiting for network to come up (attempt $attempt of $attempts)"
|
MSRVIP=10.66.166.42
|
||||||
attempt=$((attempt + 1))
|
elif [ "$test_profile" =~ *"-airgap" ]; then
|
||||||
info "Sleeping 10s to try again"
|
MSRVIP=10.66.166.52
|
||||||
sleep 10;
|
fi
|
||||||
logCmd "ip a | grep '$MNIC:' | grep 'state UP'"
|
if [ -f "/root/public_ip" ]; then
|
||||||
done
|
REDIRECTHOST=$(cat /root/public_ip)
|
||||||
info "Network is up on $MNIC"
|
REDIRECTINFO=OTHER
|
||||||
|
else
|
||||||
|
REDIRECTINFO=IP
|
||||||
|
fi
|
||||||
|
ALLOW_CIDR=0.0.0.0/0
|
||||||
|
MNIC=eth0
|
||||||
|
BNICS=eth1
|
||||||
|
HOSTNAME=$install_type
|
||||||
|
WEBUSER=onionuser@somewhere.invalid
|
||||||
|
WEBPASSWD1=0n10nus3r
|
||||||
|
WEBPASSWD2=0n10nus3r
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the setup type is suppoted.
|
# Make sure the setup type is suppoted.
|
||||||
@@ -227,7 +229,7 @@ dmesg -D
|
|||||||
|
|
||||||
# Kernel consoleblank is causing whiptail progress screen to appear to hang #1084
|
# Kernel consoleblank is causing whiptail progress screen to appear to hang #1084
|
||||||
# https://github.com/Security-Onion-Solutions/securityonion/issues/1084
|
# https://github.com/Security-Onion-Solutions/securityonion/issues/1084
|
||||||
if [ "$automated" == no ]; then
|
if [ -z "$TESTING" ]; then
|
||||||
TTY=$(tty)
|
TTY=$(tty)
|
||||||
info "Setup is running on TTY $TTY"
|
info "Setup is running on TTY $TTY"
|
||||||
if echo $TTY | grep -q "/dev/tty"; then
|
if echo $TTY | grep -q "/dev/tty"; then
|
||||||
@@ -283,7 +285,7 @@ if ! [[ -f $install_opt_file ]]; then
|
|||||||
compare_main_nic_ip
|
compare_main_nic_ip
|
||||||
|
|
||||||
fi
|
fi
|
||||||
if [[ $setup_type == 'iso' ]] && [ "$automated" == no ]; then
|
if [[ $setup_type == 'iso' ]] && [ -z "$TESTING" ]; then
|
||||||
whiptail_first_menu_iso
|
whiptail_first_menu_iso
|
||||||
if [[ $option == "CONFIGURENETWORK" ]]; then
|
if [[ $option == "CONFIGURENETWORK" ]]; then
|
||||||
collect_hostname
|
collect_hostname
|
||||||
|
|||||||
Reference in New Issue
Block a user