Install setup required packages later so that also uses the proxy

This commit is contained in:
William Wernert
2021-03-11 15:20:39 -05:00
parent 0d01f63e3b
commit e60bc87ffa
2 changed files with 54 additions and 31 deletions

View File

@@ -997,11 +997,19 @@ detect_os() {
} }
installer_progress_loop() {
local i=0
while true; do
((i++))
set_progress_str "$i" 'Checking that all required packages are installed and enabled...'
[[ $i -gt 0 ]] && sleep 5s
done
}
installer_prereq_packages() { installer_prereq_packages() {
if [ "$OS" == centos ]; then if [ "$OS" == centos ]; then
# Print message to stdout so the user knows setup is doing something # Print message to stdout so the user knows setup is doing something
echo "Installing required packages to run installer..."
# Install bind-utils so the host command exists # Install bind-utils so the host command exists
if [[ ! $is_iso ]]; then if [[ ! $is_iso ]]; then
if ! command -v host > /dev/null 2>&1; then if ! command -v host > /dev/null 2>&1; then
@@ -1009,9 +1017,9 @@ installer_prereq_packages() {
fi fi
if ! command -v nmcli > /dev/null 2>&1; then if ! command -v nmcli > /dev/null 2>&1; then
{ {
yum -y install NetworkManager; yum -y install NetworkManager
systemctl enable NetworkManager; systemctl enable NetworkManager
systemctl start NetworkManager; systemctl start NetworkManager
} >> "$setup_log" 2<&1 } >> "$setup_log" 2<&1
fi fi
if ! command -v bc > /dev/null 2>&1; then if ! command -v bc > /dev/null 2>&1; then
@@ -1026,7 +1034,6 @@ installer_prereq_packages() {
fi fi
elif [ "$OS" == ubuntu ]; then elif [ "$OS" == ubuntu ]; then
# Print message to stdout so the user knows setup is doing something # Print message to stdout so the user knows setup is doing something
echo "Installing required packages to run installer..."
retry 50 10 "apt-get update" >> "$setup_log" 2>&1 || exit 1 retry 50 10 "apt-get update" >> "$setup_log" 2>&1 || exit 1
# Install network manager so we can do interface stuff # Install network manager so we can do interface stuff
if ! command -v nmcli > /dev/null 2>&1; then if ! command -v nmcli > /dev/null 2>&1; then

View File

@@ -94,16 +94,27 @@ if ! [ -f $install_opt_file ]; then
fi fi
automated=no automated=no
function progress() { progress() {
local title='Security Onion Install' local title='Security Onion Setup'
local msg=${1:-'Please wait while installing...'}
if [ $automated == no ]; then if [ $automated == no ]; then
whiptail --title "$title" --gauge 'Please wait while installing...' 6 60 0 # append to text whiptail --title "$title" --gauge "$msg" 6 70 0 # append to text
else else
cat >> $setup_log 2>&1 cat >> $setup_log 2>&1
fi fi
} }
# Set up handler for setup to exit early (use `kill -SIGUSR1 "$setup_proc"; exit 1` in child scripts)
trap 'catch $LINENO' SIGUSR1
setup_proc="$$"
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
}
detect_os detect_os
if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then if [[ -f automation/$automation && $(basename $automation) == $automation ]]; then
@@ -198,17 +209,14 @@ if ! [[ -f $install_opt_file ]]; then
printf '%s\n' \ printf '%s\n' \
"MNIC=$MNIC" \ "MNIC=$MNIC" \
"HOSTNAME=$HOSTNAME" > "$net_init_file" "HOSTNAME=$HOSTNAME" > "$net_init_file"
if [[ $is_manager ]]; then
collect_proxy collect_proxy
[[ -n "$so_proxy" ]] && set_proxy >> $setup_log 2>&1 [[ -n "$so_proxy" ]] && set_proxy >> $setup_log 2>&1
fi
whiptail_net_setup_complete whiptail_net_setup_complete
else else
whiptail_install_type true
fi fi
else
whiptail_install_type
fi fi
whiptail_install_type
else else
source $install_opt_file source $install_opt_file
fi fi
@@ -261,6 +269,24 @@ if [[ ( $is_manager || $is_import ) && $is_iso ]]; then
fi fi
fi fi
if [[ $is_airgap != true ]]; then
collect_proxy
fi
{
installer_progress_loop & # Run progress bar to 100 in ~8 minutes
progress_bg_proc=$!
installer_prereq_packages
install_success=$?
kill -9 $progress_bg_proc
if [[ $install_success -gt 0 ]]; then
error "Could not install packages required for setup, exiting now."
kill -SIGUSR1 "$setup_proc"; exit 1
fi
set_progress_str 99 "Detecting whether setup is running in the cloud."
detect_cloud
} | progress '...'
if ! [[ -f $install_opt_file ]]; then if ! [[ -f $install_opt_file ]]; then
if [[ $is_manager && $is_sensor ]]; then if [[ $is_manager && $is_sensor ]]; then
check_requirements "standalone" check_requirements "standalone"
@@ -535,16 +561,6 @@ whiptail_make_changes
# From here on changes will be made. # From here on changes will be made.
echo "1" > /root/accept_changes echo "1" > /root/accept_changes
# Set up handler for setup to exit early (use `kill -SIGUSR1 "$(ps --pid $$ -oppid=)"; exit 1` in child scripts)
trap 'catch $LINENO' SIGUSR1
catch() {
info "Fatal error occurred at $1 in so-setup, failing setup."
grep --color=never "ERROR" "$setup_log" > "$error_log"
whiptail_setup_failed
exit
}
# This block sets REDIRECTIT which is used by a function outside the below subshell # This block sets REDIRECTIT which is used by a function outside the below subshell
set_main_ip >> $setup_log 2>&1 set_main_ip >> $setup_log 2>&1
compare_main_nic_ip compare_main_nic_ip