diff --git a/terraform/environments/scripts/wait-for-ssl.sh b/terraform/environments/scripts/wait-for-ssl.sh index e130aadf5d8efde49192249d4b826ffd64a61ef6..2a53fa605f62bcdb379948e214c8718565f6cc51 100755 --- a/terraform/environments/scripts/wait-for-ssl.sh +++ b/terraform/environments/scripts/wait-for-ssl.sh @@ -7,7 +7,7 @@ url="$1" # google has a cdn answering on requests. This cdn takes a while to be fully updated. # Therefore, we don't return on first success, but on a number of consecutive successes. -number_of_consecutive_successful_tries_needed=10 +number_of_consecutive_successful_tries_needed=25 number_of_consecutive_successful_tries_achieved=0 [ -z "$url" ] && echo "missing url as first param" && exit 1 @@ -17,10 +17,21 @@ echo -n "Checking if SSL certificate for $url is installed: " # storage for the return value of the curl command retval=0 +# early break on success (no need to wait on existing deployments) +set +e +curl -sSLIm 10 "$url" > /dev/null 2>& 1 +retval=$? +set -e +if [ $retval -eq 0 ]; then + echo "success on first try, not checking further" + exit 0 +fi + + # shellcheck disable=SC2034 for i in {1..2500}; do set +e - out=$(curl -sSLI "$url" 2>&1) + out=$(curl -sSLIm 10 "$url" 2>& 1) retval=$? set -e # shellcheck disable=SC2181 @@ -31,6 +42,7 @@ for i in {1..2500}; do echo "test successful after $i total tries" exit 0 fi + sleep 1 else echo -n "." number_of_consecutive_successful_tries_achieved=0