#!/usr/bin/env bash
# Generates JWT_SECRET, SECRET_KEY and INTERNAL_TOKEN in the exact format Gitea expects.
# Run once, then paste the three lines into Zerops as secret env vars for the gitea service.
set -euo pipefail

GITEA_VERSION="${GITEA_VERSION:-1.26.1}"
BIN=$(mktemp)
trap 'rm -f "$BIN"' EXIT

wget -qO "$BIN" "https://dl.gitea.com/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64"
chmod +x "$BIN"

echo "JWT_SECRET=$("$BIN" generate secret JWT_SECRET)"
echo "LFS_JWT_SECRET=$("$BIN" generate secret LFS_JWT_SECRET)"
echo "SECRET_KEY=$("$BIN" generate secret SECRET_KEY)"
echo "INTERNAL_TOKEN=$("$BIN" generate secret INTERNAL_TOKEN)"
