Files
git.stella-ops.org/devops/compose/scripts/gitea-entrypoint.sh
master 50abd2137f Update docs, sprint plans, and compose configuration
Add 12 new sprint files (Integrations, Graph, JobEngine, FE, Router,
AdvisoryAI), archive completed scheduler UI sprint, update module
architecture docs (router, graph, jobengine, web, integrations),
and add Gitea entrypoint script for local dev.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 08:53:50 +03:00

67 lines
1.9 KiB
Bash

#!/bin/sh
set -eu
GITEA_CONFIG="${GITEA_APP_INI:-/etc/gitea/app.ini}"
GITEA_WORK_PATH="${GITEA_WORK_DIR:-/var/lib/gitea}"
GITEA_HTTP_PORT="${GITEA__server__HTTP_PORT:-3000}"
GITEA_ADMIN_USERNAME="${GITEA_LOCAL_ADMIN_USERNAME:-stellaops}"
GITEA_ADMIN_PASSWORD="${GITEA_LOCAL_ADMIN_PASSWORD:-Stella2026!}"
GITEA_ADMIN_EMAIL="${GITEA_LOCAL_ADMIN_EMAIL:-stellaops@gitea.stella-ops.local}"
GITEA_BOOTSTRAP_SENTINEL="${GITEA_BOOTSTRAP_SENTINEL:-${GITEA_WORK_PATH}/data/.local-admin-ready}"
mkdir -p "${GITEA_WORK_PATH}/git/repositories"
/usr/local/bin/docker-entrypoint.sh "$@" &
gitea_pid=$!
cleanup() {
if kill -0 "${gitea_pid}" 2>/dev/null; then
kill "${gitea_pid}" 2>/dev/null || true
wait "${gitea_pid}" 2>/dev/null || true
fi
}
trap cleanup INT TERM
ready=0
attempt=0
while [ "${attempt}" -lt 60 ]; do
if wget -qO- "http://127.0.0.1:${GITEA_HTTP_PORT}/api/v1/version" >/dev/null 2>&1; then
ready=1
break
fi
if ! kill -0 "${gitea_pid}" 2>/dev/null; then
wait "${gitea_pid}"
exit 1
fi
attempt=$((attempt + 1))
sleep 1
done
if [ "${ready}" -ne 1 ]; then
echo "Gitea did not become ready for local admin bootstrap" >&2
wait "${gitea_pid}"
exit 1
fi
existing_admins="$(gitea admin user list --config "${GITEA_CONFIG}" --work-path "${GITEA_WORK_PATH}" --admin | tail -n +2 | awk 'BEGIN { first = 1 } NF { if (!first) printf ","; printf "%s", $2; first = 0 }')"
if [ -z "${existing_admins}" ]; then
gitea admin user create \
--config "${GITEA_CONFIG}" \
--work-path "${GITEA_WORK_PATH}" \
--username "${GITEA_ADMIN_USERNAME}" \
--password "${GITEA_ADMIN_PASSWORD}" \
--email "${GITEA_ADMIN_EMAIL}" \
--admin \
--must-change-password=false
else
echo "Gitea admin bootstrap skipped; existing admin users: ${existing_admins}"
fi
touch "${GITEA_BOOTSTRAP_SENTINEL}"
wait "${gitea_pid}"