#!/bin/sh set -eu AUTH_PY_IN_CONTAINER="/code/utilities/prosody/auth_django.py" STACK_ID="${GIA_STACK_ID:-${STACK_ID:-}}" STACK_ID="$(echo "$STACK_ID" | tr -cs 'a-zA-Z0-9._-' '-' | sed 's/^-*//; s/-*$//')" if [ -n "$STACK_ID" ]; then GIA_CONTAINER="gia_${STACK_ID}" else GIA_CONTAINER="gia" fi # Prosody external auth uses line-oriented stdin/stdout. # We execute one short-lived auth check per line to avoid stale stdin issues # in long-lived `podman exec -i` sessions after disconnects/restarts. while IFS= read -r line; do if [ -z "$line" ]; then printf '0\n' continue fi printf '%s\n' "$line" | podman exec -i "$GIA_CONTAINER" sh -lc ' cd /code && . /venv/bin/activate && exec python -u '"$AUTH_PY_IN_CONTAINER"' --once ' done