21 lines
531 B
Bash
21 lines
531 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
socket=${SPIRE_AGENT_SOCKET:-/run/spire/agent-sockets/spire-agent.sock}
|
|
wait_seconds=${SPIFFE_IDENTITY_WAIT_SECONDS:-60}
|
|
deadline=$(( $(date +%s) + wait_seconds ))
|
|
|
|
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
if timeout 2 /opt/spire/bin/spire-agent api fetch jwt \
|
|
-audience ci-job-ready \
|
|
-socketPath "$socket" \
|
|
>/dev/null 2>&1; then
|
|
/usr/local/libexec/setup-job-docker
|
|
exit 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo "timed out waiting for the job SPIFFE identity" >&2
|
|
exit 1
|