games_app/deploy/gitea-stack/bootstrap-gitea-admin.sh
Your Name 5ce6a6811a
Some checks failed
CI / test-and-build (push) Failing after 25s
Add Gitea CI/CD stack, tloto-deploy, and tagged Compose images
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 19:56:39 +02:00

31 lines
898 B
Bash

#!/usr/bin/env bash
# Create Gitea admin user (idempotent). Requires gitea container healthy.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
set -a; source .env; set +a
echo "Waiting for Gitea..."
for i in $(seq 1 60); do
if curl -fsS -m 3 "http://127.0.0.1:${GITEA_HTTP_PORT:-3000}/" >/dev/null 2>&1; then
break
fi
sleep 2
done
# Create admin if missing (must run as user git — not root)
GITEA_CLI=(sudo docker exec -u git tloto_gitea gitea)
if "${GITEA_CLI[@]}" admin user list 2>/dev/null | grep -q "${GITEA_ADMIN_USER}"; then
echo "Admin ${GITEA_ADMIN_USER} already exists"
else
"${GITEA_CLI[@]}" admin user create \
--admin \
--username "${GITEA_ADMIN_USER}" \
--password "${GITEA_ADMIN_PASSWORD}" \
--email "${GITEA_ADMIN_EMAIL}" \
--must-change-password=false
echo "Created admin ${GITEA_ADMIN_USER}"
fi
echo "ADMIN_BOOTSTRAP_OK"