From 23110d3b336b13f938ad801d424b5cefdbf39fde Mon Sep 17 00:00:00 2001 From: TOoSmOotH Date: Wed, 16 Dec 2020 17:23:51 -0500 Subject: [PATCH] Make sure thehive is up then soup --- salt/common/tools/sbin/soup | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/salt/common/tools/sbin/soup b/salt/common/tools/sbin/soup index 8c8fd7807..7a15c733a 100755 --- a/salt/common/tools/sbin/soup +++ b/salt/common/tools/sbin/soup @@ -342,9 +342,26 @@ space_check() { } thehive_maint() { - echo "Migrating thehive databases if needed." - curl -v -k -XPOST -L "https://localhost/thehive/api/maintenance/migrate" - curl -v -k -XPOST -L "https://localhost/cortex/api/maintenance/migrate" + echo -n "Waiting for TheHive..." + COUNT=0 + THEHIVE_CONNECTED="no" + while [[ "$COUNT" -le 240 ]]; do + curl --output /dev/null --silent --head --fail -k "https://localhost/thehive" + if [ $? -eq 0 ]; then + THEHIVE_CONNECTED="yes" + echo "connected!" + break + else + ((COUNT+=1)) + sleep 1 + echo -n "." + fi + done + if [ "$THEHIVE_CONNECTED" == "yes" ]; then + echo "Migrating thehive databases if needed." + curl -v -k -XPOST -L "https://localhost/thehive/api/maintenance/migrate" + curl -v -k -XPOST -L "https://localhost/cortex/api/maintenance/migrate" + fi } unmount_update() {