From d67122a0995a57e9d7e1c7bf4bb14a88312d87a7 Mon Sep 17 00:00:00 2001 From: pemontto Date: Wed, 17 Apr 2019 14:40:07 +1000 Subject: [PATCH] Retry template installation a few times --- resources/elk6/init_kibana.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/resources/elk6/init_kibana.sh b/resources/elk6/init_kibana.sh index be666aa..eca079d 100755 --- a/resources/elk6/init_kibana.sh +++ b/resources/elk6/init_kibana.sh @@ -16,11 +16,17 @@ until curl -s "$elasticsearch_url/_cluster/health?pretty" | grep '"status"' | gr sleep 5 done -echo "Loading VulnWhisperer index template" -if curl -s --fail -XPUT "http://$elasticsearch_url/_template/vulnwhisperer" -H 'Content-Type: application/json' -d '@/opt/index-template.json'; then - echo -e "\nVulnWhisperer index template loaded successfully!" +count=0 +until curl -s --fail -XPUT "http://$elasticsearch_url/_template/vulnwhisperer" -H 'Content-Type: application/json' -d '@/opt/index-template.json'; do + echo "Loading VulnWhisperer index template..." + ((count++)) && ((count==60)) && break + sleep 1 +done + +if [[ count -le 60 && $(curl -s -I http://$elasticsearch_url/_template/vulnwhisperer | head -n1 |cut -d$' ' -f2) == "200" ]]; then + echo -e "\n✅ VulnWhisperer index template loaded" else - echo -e "\nFAILED to load VulnWhisperer index template" + echo -e "\n❌ VulnWhisperer index template failed to load" fi until [ "`curl -s -I "$kibana_url"/status | head -n1 |cut -d$' ' -f2`" == "200" ]; do