mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
[fix] Add conditions for commands so they're less likely to fail
This commit is contained in:
@@ -1410,27 +1410,37 @@ reserve_group_ids() {
|
||||
}
|
||||
|
||||
reinstall_init() {
|
||||
local minion_config=/etc/salt/minion
|
||||
|
||||
info "Putting system in state to run setup again"
|
||||
info "Some commands may fail depending on whether setup previously succeeded"
|
||||
|
||||
{
|
||||
# Remove startup_states from minion config so we don't immediately highstate when salt starts back up
|
||||
sed -i '/startup_states/d' $minion_config
|
||||
local minion_config=/etc/salt/minion
|
||||
|
||||
# Remove startup_states from minion config so we don't immediately highstate when salt starts back up
|
||||
if [[ -f $minion_config ]] && grep -q "startup_states" $minion_config; then
|
||||
sed -i '/startup_states/d' $minion_config
|
||||
fi
|
||||
|
||||
if command -v salt-call &> /dev/null; then
|
||||
# Disable schedule so highstate doesn't start running during the install
|
||||
salt-call -l info schedule.disable
|
||||
|
||||
# Kill any currently running salt jobs, also to prevent issues with highstate.
|
||||
salt-call -l info saltutil.kill_all_jobs
|
||||
fi
|
||||
|
||||
if command -v docker &> /dev/null; then
|
||||
# Stop and remove all so-* containers so files can be changed with more safety
|
||||
docker stop $(docker ps -a -q --filter "name=so-")
|
||||
docker rm -f $(docker ps -a -q --filter "name=so-")
|
||||
fi
|
||||
|
||||
local date_string
|
||||
date_string=$(date +%s)
|
||||
|
||||
# Backup /opt/so since we'll be rebuilding this directory during setup
|
||||
mv /opt/so "/opt/so_old_$(date +%s)"
|
||||
if [[ -d /opt/so ]]; then
|
||||
mv /opt/so "/opt/so_old_${date_string}"
|
||||
fi
|
||||
|
||||
# Remove container data directories
|
||||
rm -rf /nsm/mysql
|
||||
|
||||
Reference in New Issue
Block a user