From 5920a144788f23d2ae38d92854cf7b541bf9d15f Mon Sep 17 00:00:00 2001 From: Josh Brower Date: Thu, 16 Nov 2023 20:34:01 -0500 Subject: [PATCH] Move API check logic --- salt/kibana/tools/sbin/so-kibana-api-check | 20 ++++++++++++++++++++ salt/manager/tools/sbin/soup | 19 +------------------ 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 salt/kibana/tools/sbin/so-kibana-api-check diff --git a/salt/kibana/tools/sbin/so-kibana-api-check b/salt/kibana/tools/sbin/so-kibana-api-check new file mode 100644 index 000000000..15cd85b19 --- /dev/null +++ b/salt/kibana/tools/sbin/so-kibana-api-check @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Copyright Security Onion Solutions LLC and/or licensed to Security Onion Solutions LLC under one +# or more contributor license agreements. Licensed under the Elastic License 2.0 as shown at +# https://securityonion.net/license; you may not use this file except in compliance with the +# Elastic License 2.0. + +. /usr/sbin/so-common + +echo "Checking to make sure that Kibana API is up & ready..." +RETURN_CODE=0 +wait_for_web_response "http://localhost:5601/api/fleet/settings" "fleet" 300 "curl -K /opt/so/conf/elasticsearch/curl.config" +RETURN_CODE=$? +if [[ "$RETURN_CODE" != "0" ]]; then + echo "Kibana API not accessible, exiting script..." + exit 1 +fi + + + diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index 67b291ddf..0de956da1 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -534,15 +534,6 @@ up_to_2.4.30() { rm -f /opt/so/conf/elastic-fleet/integrations/endpoints-initial/elastic-defend-endpoints.json . /usr/sbin/so-elastic-fleet-common - echo "Checking to make sure that Kibana API is up & ready..." - RETURN_CODE=0 - wait_for_web_response "http://localhost:5601/api/fleet/settings" "fleet" 300 "curl -K /opt/so/conf/elasticsearch/curl.config" - RETURN_CODE=$? - if [[ "$RETURN_CODE" != "0" ]]; then - echo "Kibana API not accessible, exiting script..." - exit 1 - fi - elastic_fleet_integration_remove endpoints-initial elastic-defend-endpoints /usr/sbin/so-elastic-fleet-integration-policy-elastic-defend @@ -756,17 +747,9 @@ apply_hotfix() { elif [[ "$INSTALLEDVERSION" == "2.4.30" ]] ; then rm -f /opt/so/conf/elastic-fleet/integrations/endpoints-initial/elastic-defend-endpoints.json so-kibana-restart --force + so-kibana-api-check . /usr/sbin/so-elastic-fleet-common - echo "Checking to make sure that Kibana API is up & ready..." - RETURN_CODE=0 - wait_for_web_response "http://localhost:5601/api/fleet/settings" "fleet" 300 "curl -K /opt/so/conf/elasticsearch/curl.config" - RETURN_CODE=$? - if [[ "$RETURN_CODE" != "0" ]]; then - echo "Kibana API not accessible, exiting script..." - exit 1 - fi - elastic_fleet_integration_remove endpoints-initial elastic-defend-endpoints /usr/sbin/so-elastic-fleet-integration-policy-elastic-defend salt-call state.highstate