2022-10-12 14:22:22 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function error_handler() {
|
|
|
|
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
|
|
|
exit "$2"
|
|
|
|
}
|
|
|
|
trap 'error_handler ${LINENO} $?' ERR
|
|
|
|
set -o errtrace -o errexit -o nounset -o pipefail
|
|
|
|
|
2023-02-16 20:05:55 +00:00
|
|
|
max_attempts="${1:-100}"
|
|
|
|
port="${2:-7002}"
|
2022-10-12 14:22:22 +00:00
|
|
|
|
2023-02-16 20:19:01 +00:00
|
|
|
echo "waiting for keycloak to come up..."
|
2022-10-12 14:22:22 +00:00
|
|
|
attempts=0
|
2023-02-16 20:05:55 +00:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${port}/realms/master/.well-known/openid-configuration")" != "200" ]]; do
|
2022-10-12 14:22:22 +00:00
|
|
|
if [[ "$attempts" -gt "$max_attempts" ]]; then
|
|
|
|
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
attempts=$(( attempts + 1 ))
|
|
|
|
sleep 1
|
|
|
|
done
|
2023-02-16 20:19:01 +00:00
|
|
|
echo "keycloak up"
|