Create init.sh

This commit is contained in:
2025-09-10 23:24:54 -07:00
committed by GitHub
parent d4c6561f8c
commit 3bf1facfbb

35
init.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env sh
set -eu
mkdir -p /data/gitea/conf /data/gitea/custom /data/custom /data/caddy
# Bootstrap Gitea
if [ ! -f /data/.bootstrapped ]; then
/usr/local/bin/gitea migrate
/usr/local/bin/gitea admin user create --admin \
--username "${GITEA_ADMIN_USER}" \
--password "${GITEA_ADMIN_PASSWD}" \
--email "${GITEA_ADMIN_EMAIL}" || true
touch /data/.bootstrapped
fi
# Pull Gitea customizations
if [ -n "${CUSTOM_REPO_URL:-}" ]; then
if [ ! -d /data/custom/.git ]; then
git clone --depth 1 "${CUSTOM_REPO_URL}" /data/custom || true
else
git -C /data/custom pull --ff-only || true
fi
rsync -a --delete /data/custom/ /data/gitea/custom/
fi
# Pull Caddy config
if [ -n "${CADDY_REPO_URL:-}" ]; then
if [ ! -d /data/caddyrepo/.git ]; then
git clone --depth 1 "${CADDY_REPO_URL}" /data/caddyrepo || true
else
git -C /data/caddyrepo pull --ff-only || true
fi
if [ -f "/data/caddyrepo/Caddyfile" ]; then
cp "/data/caddyrepo/Caddyfile" /data/caddy/Caddyfile
fi
fi