mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
[refactor] Run all changes inside whiptail progress, use grep -q
This commit is contained in:
@@ -766,12 +766,12 @@ detect_os() {
|
|||||||
|
|
||||||
disable_auto_start() {
|
disable_auto_start() {
|
||||||
|
|
||||||
if crontab -l -u $INSTALLUSERNAME 2>&1 | grep so-setup > /dev/null 2>&1; then
|
if crontab -l -u $INSTALLUSERNAME 2>&1 | grep -q so-setup; then
|
||||||
# Remove the automated setup script from crontab, if it exists
|
# Remove the automated setup script from crontab, if it exists
|
||||||
logCmd "crontab -u $INSTALLUSERNAME -r"
|
logCmd "crontab -u $INSTALLUSERNAME -r"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep so-setup /home/$INSTALLUSERNAME/.bash_profile > /dev/null 2>&1; then
|
if grep -q so-setup /home/$INSTALLUSERNAME/.bash_profile; then
|
||||||
# Truncate last line of the bash profile
|
# Truncate last line of the bash profile
|
||||||
info "Removing auto-run of setup from bash profile"
|
info "Removing auto-run of setup from bash profile"
|
||||||
sed -i '$ d' /home/$INSTALLUSERNAME/.bash_profile >> "$setup_log" 2>&1
|
sed -i '$ d' /home/$INSTALLUSERNAME/.bash_profile >> "$setup_log" 2>&1
|
||||||
|
|||||||
@@ -428,6 +428,25 @@ 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 $2 in so-setup, failing setup."
|
||||||
|
whiptail_setup_failed
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Begin install
|
||||||
|
{
|
||||||
|
# Set initial percentage to 0
|
||||||
|
export percentage=0
|
||||||
|
|
||||||
|
# Show initial progress message
|
||||||
|
set_progress_str 0 'Running initial configuration steps'
|
||||||
|
|
||||||
|
set_path
|
||||||
|
|
||||||
if [[ $is_reinstall ]]; then
|
if [[ $is_reinstall ]]; then
|
||||||
reinstall_init
|
reinstall_init
|
||||||
fi
|
fi
|
||||||
@@ -438,7 +457,7 @@ fi
|
|||||||
|
|
||||||
if [[ "$setup_type" == 'iso' ]]; then
|
if [[ "$setup_type" == 'iso' ]]; then
|
||||||
# Init networking so rest of install works
|
# Init networking so rest of install works
|
||||||
set_hostname
|
set_hostname >> $setup_log 2>&1
|
||||||
set_management_interface
|
set_management_interface
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -446,7 +465,7 @@ disable_ipv6
|
|||||||
disable_auto_start
|
disable_auto_start
|
||||||
|
|
||||||
if [[ "$setup_type" != 'iso' ]]; then
|
if [[ "$setup_type" != 'iso' ]]; then
|
||||||
set_hostname
|
set_hostname >> $setup_log 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $is_minion ]]; then
|
if [[ $is_minion ]]; then
|
||||||
@@ -483,22 +502,6 @@ if [[ $is_minion || $is_import ]]; then
|
|||||||
[ "$automated" == no ] && copy_ssh_key >> $setup_log 2>&1
|
[ "$automated" == no ] && copy_ssh_key >> $setup_log 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Exit parent script if
|
|
||||||
trap 'catch $LINENO' SIGUSR1
|
|
||||||
|
|
||||||
catch() {
|
|
||||||
info "Fatal error occurred at $2 in so-setup, failing setup."
|
|
||||||
whiptail_setup_failed
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
|
|
||||||
# Begin install
|
|
||||||
{
|
|
||||||
# Set initial percentage to 0
|
|
||||||
export percentage=0
|
|
||||||
set_path
|
|
||||||
|
|
||||||
if [[ $is_manager && $is_airgap ]]; then
|
if [[ $is_manager && $is_airgap ]]; then
|
||||||
info "Creating airgap repo"
|
info "Creating airgap repo"
|
||||||
create_repo >> $setup_log 2>&1
|
create_repo >> $setup_log 2>&1
|
||||||
|
|||||||
Reference in New Issue
Block a user