#!/usr/bin/env bash # rig forgejo-runner install — Forgejo Actions runner as a systemd service # under an unprivileged user. Outbound-only (long-poll to the instance), no # inbound ports. Convergent toward --instance: re-running against the instance # the box is already on leaves it alone; a box registered to a DIFFERENT # instance is refused, never silently restarted on the old one. # # The GitHub sibling (runner-install.sh) refuses Docker outright: it converges # a fleet MACHINE, where `docker` group membership is root-equivalent and the # blast radius is the machine. This command's home is a ci-box TENANT, where # bootstrap-tenant.sh has already installed Docker and added the tenant user to # the group, and where the blast radius is a disposable guest with no inbound # path. Same trade, different machine, opposite answer — which is why this is a # separate command and not a flag on that one. set -euo pipefail HERE="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" # shellcheck source=SCRIPTDIR/lib/forgejo-runner-config.sh . "$HERE/lib/forgejo-runner-config.sh" log() { printf 'rig-forgejo-runner: %s\n' "$*"; } warn() { printf 'rig-forgejo-runner: WARNING: %s\n' "$*" >&2; } die() { printf 'rig-forgejo-runner: ERROR: %s\n' "$1" >&2; exit "${2:-1}"; } # The default label map. `runs-on: ubuntu-latest` is what a workflow written # for GitHub says, so it must mean something here or every workflow needs # editing to migrate; catthehacker's image is the act/Forgejo ecosystem's # stand-in for GitHub's runner image. `docker` is the lean second option. # # Both are `docker://` — jobs run in CONTAINERS on the box's own dockerd, not # on the box itself. No docker-in-docker: the guide this came from stacks a # privileged dind sidecar with a plaintext tcp://…:2375 daemon to isolate jobs # from a shared CI server, and inside a box that boundary is already paid for. DEFAULT_LABELS='ubuntu-latest:docker://ghcr.io/catthehacker/ubuntu:act-22.04,docker:docker://node:22-bookworm' # fetch_and_verify_sha256