mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-08 18:22:47 +01:00
This commit is contained in:
@@ -23,11 +23,16 @@ if ! [ "$(id -u)" = 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
|
SYSTEM_START_TIME=$(date -d "$(</proc/uptime awk '{print $1}') seconds ago" +%s)
|
||||||
|
LAST_HIGHSTATE_END=$(date -r /opt/so/log/salt/lasthighstate +%s) # file populated by salt.lasthighstate state at end of successful highstate run
|
||||||
|
HIGHSTATE_RUNNING=$(salt-call --local saltutil.running --out=json | jq -r '.local[].fun' | grep -q 'state.highstate' && echo $?)
|
||||||
ERROR_STRING="ERROR"
|
ERROR_STRING="ERROR"
|
||||||
SUCCESS_STRING="OK"
|
SUCCESS_STRING="OK"
|
||||||
PENDING_STRING="PENDING"
|
PENDING_STRING="PENDING"
|
||||||
MISSING_STRING='MISSING'
|
MISSING_STRING='MISSING'
|
||||||
DISABLED_STRING='DISABLED'
|
DISABLED_STRING='DISABLED'
|
||||||
|
WAIT_START_STRING='WAIT_START'
|
||||||
|
STARTING_STRING='STARTING'
|
||||||
CALLER=$(ps -o comm= $PPID)
|
CALLER=$(ps -o comm= $PPID)
|
||||||
declare -a BAD_STATUSES=("removing" "paused" "exited" "dead")
|
declare -a BAD_STATUSES=("removing" "paused" "exited" "dead")
|
||||||
declare -a PENDING_STATUSES=("paused" "created" "restarting")
|
declare -a PENDING_STATUSES=("paused" "created" "restarting")
|
||||||
@@ -111,12 +116,16 @@ parse_status() {
|
|||||||
local container_state=${1}
|
local container_state=${1}
|
||||||
local service_name=${2}
|
local service_name=${2}
|
||||||
|
|
||||||
[[ $container_state = "missing" ]] && printf $MISSING_STRING && return 1
|
|
||||||
|
|
||||||
for state in "${GOOD_STATUSES[@]}"; do
|
for state in "${GOOD_STATUSES[@]}"; do
|
||||||
[[ $container_state = "$state" ]] && printf $SUCCESS_STRING && return 0
|
[[ $container_state = "$state" ]] && printf $SUCCESS_STRING && return 0
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# if a highstate has finished running since the system has started
|
||||||
|
# then the containers should be running so let's check the status
|
||||||
|
if [ $LAST_HIGHSTATE_END -ge $SYSTEM_START_TIME ]; then
|
||||||
|
|
||||||
|
[[ $container_state = "missing" ]] && printf $MISSING_STRING && return 1
|
||||||
|
|
||||||
for state in "${PENDING_STATUSES[@]}"; do
|
for state in "${PENDING_STATUSES[@]}"; do
|
||||||
[[ $container_state = "$state" ]] && printf $PENDING_STRING && return 0
|
[[ $container_state = "$state" ]] && printf $PENDING_STRING && return 0
|
||||||
done
|
done
|
||||||
@@ -133,6 +142,18 @@ parse_status() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
printf $ERROR_STRING && return 1
|
printf $ERROR_STRING && return 1
|
||||||
|
|
||||||
|
# if a highstate has not run since system start time, but a highstate is currently running
|
||||||
|
# then show that the containers are STARTING
|
||||||
|
elif [ $HIGHSTATE_RUNNING -eq 0 ]; then
|
||||||
|
printf $STARTING_STRING && return 0
|
||||||
|
|
||||||
|
# if a highstate has not finished running since system startup and isn't currently running
|
||||||
|
# then just show that the containers are WAIT_START; waiting to be started
|
||||||
|
else
|
||||||
|
printf $WAIT_START_STRING && return 1
|
||||||
|
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# {% raw %}
|
# {% raw %}
|
||||||
|
|||||||
0
salt/salt/lasthighstate.sls
Normal file
0
salt/salt/lasthighstate.sls
Normal file
Reference in New Issue
Block a user