From 2ec3f52ea66d2418cc7874029e17cf2c1075e02b Mon Sep 17 00:00:00 2001 From: weslambert Date: Thu, 12 Sep 2024 17:57:41 -0400 Subject: [PATCH] Don't use state; set IFS --- .../sbin/so-elastic-fleet-integration-upgrade | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-upgrade b/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-upgrade index d7f4257a9..4486e1244 100644 --- a/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-upgrade +++ b/salt/elasticfleet/tools/sbin/so-elastic-fleet-integration-upgrade @@ -6,17 +6,14 @@ . /usr/sbin/so-elastic-fleet-common -RETURN_CODE=0 +# Let's snag a cookie from Kibana +SESSIONCOOKIE=$(curl -s -K /opt/so/conf/elasticsearch/curl.config -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}') -if [ ! -f /opt/so/state/eaintegrationupgrade.txt ]; then - # Let's snag a cookie from Kibana - SESSIONCOOKIE=$(curl -s -K /opt/so/conf/elasticsearch/curl.config -c - -X GET http://localhost:5601/ | grep sid | awk '{print $7}') - - # List agent policies - for AGENT_POLICY in $(elastic_fleet_agent_policy_names); do - IFS=$'\n' - for INTEGRATION in $(elastic_fleet_integration_policy_names "$AGENT_POLICY"); do - if ! [[ "$INTEGRATION" == "elastic-defend-endpoints" ]] && ! [[ "$INTEGRATION" == "fleet_server-"* ]]; then +# List agent policies +for AGENT_POLICY in $(elastic_fleet_agent_policy_names); do + IFS=$'\n' + for INTEGRATION in $(elastic_fleet_integration_policy_names "$AGENT_POLICY"); do + if ! [[ "$INTEGRATION" == "elastic-defend-endpoints" ]] && ! [[ "$INTEGRATION" == "fleet_server-"* ]]; then # Get package name so we know what package to look for when checking the current and latest available version PACKAGE_NAME=$(elastic_fleet_integration_policy_package_name "$AGENT_POLICY" "$INTEGRATION") # Get currently installed version of package @@ -39,13 +36,7 @@ if [ ! -f /opt/so/state/eaintegrationupgrade.txt ]; then exit 1 fi fi - fi - done + fi done - if [[ "$RETURN_CODE" != "1" ]]; then - touch /opt/so/state/eaintegrationupgrade.txt - fi - echo -else - exit $RETURN_CODE -fi +done +echo