Files
runneros/mkosi.extra/usr/libexec/gitea-runner-setup
Job79andClaude Opus 5.5 018f15172d Ask for the registration and capacity at first boot
gitea-runner-setup asks on the console for the number of parallel jobs,
the Gitea URL and a registration token, and registers the runner. It runs
until the runner is registered, and logins wait for it, as for
systemd-firstboot. The capacity goes to a drop-in of gitea-runner.service,
which passes it to the config as CAPACITY, so the config stays read-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 18:57:23 +00:00

25 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# gitea-runner-setup asks on the console for the number of parallel jobs and
# the runner's registration, and registers the runner. gitea-runner.path then
# starts it. gitea-runner-setup.service runs it until the runner is registered.
#
# The capacity goes to a drop-in of gitea-runner.service, which passes it to
# /etc/gitea-runner/config.yaml as CAPACITY. It is written first, because the
# runner starts as soon as it is registered.
set -euo pipefail
read -rp "Parallel jobs [1]: " capacity
[[ $capacity =~ ^[1-9][0-9]*$ ]] || capacity=1
mkdir -p /etc/systemd/system/gitea-runner.service.d
printf '[Service]\nEnvironment=CAPACITY=%s\n' "$capacity" \
> /etc/systemd/system/gitea-runner.service.d/capacity.conf
systemctl daemon-reload
export CAPACITY=$capacity
until [[ -f /var/lib/gitea-runner/.runner ]]; do
read -rp "Gitea URL: " url
read -rp "Registration token: " token
gitea-runner -c /etc/gitea-runner/config.yaml register --no-interactive \
--instance "$url" --token "$token" || echo "Try again."
done