Files
mtusi2026lab7/scripts/wait-ready.sh
2026-11-27 16:42:18 +03:00

29 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# Ожидание HTTPS readiness через Traefik с проверкойCA. --insecure не используется.
set -eu
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT"
URL="${READY_URL:-https://localhost:8443/health/ready}"
# Относительный путь понимают и Linux curl, и Windows schannel curl.
CA="${CA_FILE:-certs/ca.crt}"
LIMIT="${READY_TIMEOUT_SECONDS:-180}"
# Windows schannel не умеет проверять revocation локального CA без CRL;
# отключаем только проверку revocation, но не проверку цепочки/hostname.
CURL_OPTS=""
case "$(uname -s 2>/dev/null || true)" in
MINGW*|MSYS*|CYGWIN*) CURL_OPTS="--ssl-no-revoke" ;;
esac
i=0
while [ "$i" -lt "$LIMIT" ]; do
if curl $CURL_OPTS -fsS --cacert "$CA" "$URL" >/dev/null 2>&1; then
printf 'ready: %s\n' "$URL"
exit 0
fi
i=$((i + 1))
sleep 1
done
printf 'not ready after %ss: %s\n' "$LIMIT" "$URL" >&2
exit 1