From 8da070d5118d4862f2e78db8e48f8944aef53dbb Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Thu, 5 Nov 2020 17:46:23 -0500 Subject: [PATCH 1/8] https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 53 ++++++++++++++++++++++---------- salt/salt/lasthighstate.sls | 0 2 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 salt/salt/lasthighstate.sls diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 519d9f39d..714e71bc9 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -23,11 +23,16 @@ if ! [ "$(id -u)" = 0 ]; then fi # Constants +SYSTEM_START_TIME=$(date -d "$( Date: Thu, 5 Nov 2020 17:51:51 -0500 Subject: [PATCH 2/8] https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 2 +- salt/salt/lasthighstate.sls | 4 ++++ salt/top.sls | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 714e71bc9..05f32d7ce 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -24,7 +24,7 @@ fi # Constants SYSTEM_START_TIME=$(date -d "$( Date: Thu, 5 Nov 2020 17:52:28 -0500 Subject: [PATCH 3/8] https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 05f32d7ce..26d390454 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -24,7 +24,8 @@ fi # Constants SYSTEM_START_TIME=$(date -d "$( Date: Thu, 5 Nov 2020 17:54:10 -0500 Subject: [PATCH 4/8] https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 26d390454..8d50bc2fd 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -25,7 +25,7 @@ fi # Constants SYSTEM_START_TIME=$(date -d "$( Date: Thu, 5 Nov 2020 18:03:42 -0500 Subject: [PATCH 5/8] add color - https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 8d50bc2fd..17bf50523 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -167,11 +167,11 @@ print_line() { local PADDING_CONSTANT=14 - if [[ $service_state = "$ERROR_STRING" ]] || [[ $service_state = "$MISSING_STRING" ]]; then + if [[ $service_state = "$ERROR_STRING" ]] || [[ $service_state = "$MISSING_STRING" ]] || [[ $service_state = "$WAIT_START_STRING" ]]; then state_color="\e[1;31m" elif [[ $service_state = "$SUCCESS_STRING" ]]; then state_color="\e[1;32m" - elif [[ $service_state = "$PENDING_STRING" ]] || [[ $service_state = "$DISABLED_STRING" ]]; then + elif [[ $service_state = "$PENDING_STRING" ]] || [[ $service_state = "$DISABLED_STRING" ]] || [[ $service_state = "$STARTING_STRING" ]]; then state_color="\e[1;33m" fi From c7b4a5351cb99325a412bfd09301bfd2332d7792 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Thu, 5 Nov 2020 18:17:11 -0500 Subject: [PATCH 6/8] fix logic - https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 17bf50523..0aff7a5a2 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -146,7 +146,7 @@ parse_status() { # 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 + elif [[ "$HIGHSTATE_RUNNING" == 0 ]]; then printf $STARTING_STRING && return 0 # if a highstate has not finished running since system startup and isn't currently running From 21b284fb100334073aead4226b097ba4f31ef4df Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Thu, 5 Nov 2020 18:46:11 -0500 Subject: [PATCH 7/8] show if disabled regardless of highstate status - https://github.com/Security-Onion-Solutions/securityonion/issues/1764 --- salt/common/tools/sbin/so-status | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 0aff7a5a2..523149e25 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -121,6 +121,10 @@ parse_status() { [[ $container_state = "$state" ]] && printf $SUCCESS_STRING && return 0 done + for state in "${BAD_STATUSES[@]}"; do + [[ " ${DISABLED_CONTAINERS[@]} " =~ " ${service_name} " ]] && printf $DISABLED_STRING && return 0 + 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 @@ -133,13 +137,7 @@ parse_status() { # This is technically not needed since the default is error state for state in "${BAD_STATUSES[@]}"; do - if [[ " ${DISABLED_CONTAINERS[@]} " =~ " ${service_name} " ]]; then - printf $DISABLED_STRING - return 0 - elif [[ $container_state = "$state" ]]; then - printf $ERROR_STRING - return 1 - fi + [[ $container_state = "$state" ]] && printf $ERROR_STRING && return 1 done printf $ERROR_STRING && return 1 From 7eb0dab6c7839c53a5456c2a65988388603ff712 Mon Sep 17 00:00:00 2001 From: m0duspwnens Date: Thu, 5 Nov 2020 19:08:19 -0500 Subject: [PATCH 8/8] increase padding by 1 - https://github.com/Security-Onion-Solutions/securityonion/issues/1536 --- salt/common/tools/sbin/so-status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/common/tools/sbin/so-status b/salt/common/tools/sbin/so-status index 523149e25..904c3ae7d 100755 --- a/salt/common/tools/sbin/so-status +++ b/salt/common/tools/sbin/so-status @@ -163,7 +163,7 @@ print_line() { local columns=$(tput cols) local state_color="\e[0m" - local PADDING_CONSTANT=14 + local PADDING_CONSTANT=15 if [[ $service_state = "$ERROR_STRING" ]] || [[ $service_state = "$MISSING_STRING" ]] || [[ $service_state = "$WAIT_START_STRING" ]]; then state_color="\e[1;31m"