games_app/deploy/gitea-stack/bootstrap-env.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

50 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# Generate .env with strong secrets if missing.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
if [[ -f .env ]]; then
echo ".env already exists — skip generation"
exit 0
fi
DB_PASS="$(openssl rand -hex 24)"
SECRET_KEY="$(openssl rand -hex 32)"
# Gitea internal token format: long base64-ish string
INTERNAL_TOKEN="$(openssl rand -base64 48 | tr -d '\n')"
ADMIN_PASS="$(openssl rand -base64 24 | tr -d '\n=/+' | head -c 24)"
cat > .env <<EOF
GITEA_DOMAIN=191.215.41.53
GITEA_ROOT_URL=http://191.215.41.53:3000/
GITEA_HTTP_PORT=3000
GITEA_HTTP_BIND=0.0.0.0
GITEA_SSH_PORT=2222
GITEA_SSH_BIND=0.0.0.0
GITEA_DB_PASSWORD=${DB_PASS}
GITEA_SECRET_KEY=${SECRET_KEY}
GITEA_INTERNAL_TOKEN=${INTERNAL_TOKEN}
GITEA_RUNNER_REGISTRATION_TOKEN=
GITEA_RUNNER_NAME=tloto-vps-runner
GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:20-bookworm,ubuntu-22.04:docker://node:20-bookworm
GITEA_ADMIN_USER=tloto-admin
GITEA_ADMIN_PASSWORD=${ADMIN_PASS}
GITEA_ADMIN_EMAIL=admin@tloto.net
EOF
chmod 600 .env
CRED="$HOME/gitea-admin-credentials.txt"
cat > "$CRED" <<EOF
Gitea URL: http://191.215.41.53:3000/
User: tloto-admin
Password: ${ADMIN_PASS}
Email: admin@tloto.net
Created: $(date -u +%Y-%m-%dT%H:%M:%SZ)
EOF
chmod 600 "$CRED"
echo "Wrote .env and $CRED"