mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-07 17:52:46 +01:00
[feat] Add timeout for salt services to stop during reinstall init
This commit is contained in:
@@ -1382,6 +1382,12 @@ reserve_group_ids() {
|
|||||||
|
|
||||||
reinstall_init() {
|
reinstall_init() {
|
||||||
info "Putting system in state to run setup again"
|
info "Putting system in state to run setup again"
|
||||||
|
|
||||||
|
local salt_services=(
|
||||||
|
"salt-master"
|
||||||
|
"salt-minion"
|
||||||
|
)
|
||||||
|
local service_retry_count=20
|
||||||
|
|
||||||
{
|
{
|
||||||
# Disable all scheduled jobs
|
# Disable all scheduled jobs
|
||||||
@@ -1390,7 +1396,24 @@ reinstall_init() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Kill any salt processes (safely)
|
# Kill any salt processes (safely)
|
||||||
systemctl stop salt-*
|
for service in "${salt_services[@]}"; do
|
||||||
|
# Stop the service in the background so we can exit after a certain amount of time
|
||||||
|
systemctl stop "$service" &
|
||||||
|
local pid=$!
|
||||||
|
|
||||||
|
local count=0
|
||||||
|
while ! (check_service_status "$service"); do
|
||||||
|
if [ count > $service_retry_count ]; then
|
||||||
|
echo "Could not stop $service after 1 minute, exiting setup."
|
||||||
|
|
||||||
|
# Stop the systemctl process trying to kill the service, show user a message, then exit setup
|
||||||
|
kill -9 $pid
|
||||||
|
whiptail_service_stop_failed "$service"
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
((count++))
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
# Remove all salt configs
|
# Remove all salt configs
|
||||||
rm -rf /etc/salt/global /etc/salt/minion /etc/salt/master /etc/salt/pki/*
|
rm -rf /etc/salt/global /etc/salt/minion /etc/salt/master /etc/salt/pki/*
|
||||||
|
|||||||
@@ -1175,6 +1175,19 @@ whiptail_sensor_config() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
whiptail_service_stop_failed() {
|
||||||
|
local service=$1
|
||||||
|
|
||||||
|
read -r -d '' message <<- EOM
|
||||||
|
The ${service} service could not be stopped. Please stop it manually and then re-run setup.
|
||||||
|
|
||||||
|
Press ENTER to exit the installer.
|
||||||
|
EOM
|
||||||
|
|
||||||
|
whiptail --title "Security Onion Setup" --msgbox "$message" 10 75
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
whiptail_set_hostname() {
|
whiptail_set_hostname() {
|
||||||
|
|
||||||
[ -n "$TESTING" ] && return
|
[ -n "$TESTING" ] && return
|
||||||
|
|||||||
Reference in New Issue
Block a user