2026-11-07 16:44:51 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
# Tomter Vel's stack, brought up from its own repo. This is the whole of
|
|
|
|
|
# what CI may do as root for the vel: pull main, put the env files the
|
|
|
|
|
# deploy workflow wrote in place, and bring the compose project up. It
|
|
|
|
|
# takes no arguments, so there is nothing for a workflow to point
|
|
|
|
|
# somewhere else.
|
|
|
|
|
#
|
|
|
|
|
# The env files come from the repo's and org's Actions variables and
|
|
|
|
|
# secrets: the workflow writes them, as the runner, into $stage (the
|
|
|
|
|
# runner's own, 0700), and this script moves them into the checkout as
|
|
|
|
|
# root's, 0600, and leaves nothing behind in $stage.
|
|
|
|
|
#
|
|
|
|
|
# Install: sudo install -m 0755 -o root -g root \
|
|
|
|
|
# deploy-tomtervel /usr/local/bin/deploy-tomtervel
|
|
|
|
|
# Grant: gitea-runner ALL=(root) NOPASSWD: /usr/local/bin/deploy-tomtervel
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
root=/srv/tomtervel/infrastructure
|
|
|
|
|
stage=/var/lib/gitea-runner/tomtervel-env
|
2026-11-24 12:30:21 +01:00
|
|
|
files=(.env portal.env)
|
2026-11-10 22:27:40 +01:00
|
|
|
# Written only when the site runs what needs it (Rauthy, the money
|
|
|
|
|
# service under the pay profile).
|
|
|
|
|
optional=(rauthy.env kron.env)
|
2026-11-07 16:44:51 +01:00
|
|
|
|
|
|
|
|
[ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; }
|
|
|
|
|
for f in "${files[@]}"; do
|
|
|
|
|
[ -s "$stage/$f" ] || { echo "no $stage/$f - the deploy workflow writes it" >&2; exit 1; }
|
|
|
|
|
done
|
|
|
|
|
cd "$root"
|
|
|
|
|
|
|
|
|
|
git fetch --quiet origin main
|
|
|
|
|
git reset --hard --quiet origin/main
|
|
|
|
|
|
|
|
|
|
for f in "${files[@]}"; do
|
|
|
|
|
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
|
|
|
|
rm -f "$stage/$f"
|
|
|
|
|
done
|
2026-11-07 22:33:46 +01:00
|
|
|
for f in "${optional[@]}"; do
|
|
|
|
|
[ -s "$stage/$f" ] || continue
|
|
|
|
|
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
|
|
|
|
rm -f "$stage/$f"
|
|
|
|
|
done
|
2026-11-07 16:44:51 +01:00
|
|
|
|
|
|
|
|
# --build so a bumped PORTAL_RELEASE or GDO_RELEASE is actually fetched.
|
|
|
|
|
podman compose up -d --build
|
|
|
|
|
|
|
|
|
|
# The vel's portal, reached the way the host Caddy reaches it. No
|
|
|
|
|
# forwarded header on purpose: a check that sends the one Caddy sends
|
|
|
|
|
# cannot tell you the site is broken for everything that is not Caddy.
|
|
|
|
|
code=000
|
|
|
|
|
for n in $(seq 1 30); do
|
|
|
|
|
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3050/ || true)
|
|
|
|
|
[ "$code" = 200 ] && break
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
|
|
|
|
podman compose ps --format '{{.Names}} {{.State}}' || true
|
|
|
|
|
echo "portal http $code after $((n * 2))s"
|
|
|
|
|
[ "$code" = 200 ]
|