Files
railiance-forge/tools/haskelseed-runner-activate.sh
tegwick 19ee47fe82
Some checks failed
Forge Runner Smoke / compatibility-smoke (push) Has been cancelled
Implement Gitea Actions runner substrate
2026-06-08 00:31:06 +02:00

68 lines
1.7 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
RUNNER_HOST="${RUNNER_HOST:-192.168.178.135}"
RUNNER_SSH_USER="${RUNNER_SSH_USER:-root}"
RUNNER_SSH_KEY="${RUNNER_SSH_KEY:-/home/worsch/.ssh/id_ops}"
RUNNER_SERVICE_SOURCE="${RUNNER_SERVICE_SOURCE:-runner/act-runner-haskelseed.openrc.example}"
REMOTE_SERVICE_TMP="/tmp/act_runner.openrc.$$"
ssh_args=(-o BatchMode=yes -o ConnectTimeout=8)
if [ -n "${RUNNER_SSH_KEY}" ]; then
ssh_args+=(-i "${RUNNER_SSH_KEY}")
fi
target="${RUNNER_SSH_USER}@${RUNNER_HOST}"
scp "${ssh_args[@]}" "${RUNNER_SERVICE_SOURCE}" "${target}:${REMOTE_SERVICE_TMP}"
ssh "${ssh_args[@]}" "${target}" "REMOTE_SERVICE_TMP='${REMOTE_SERVICE_TMP}' sh -s" <<'REMOTE'
set -eu
if [ ! -f /root/.runner ]; then
echo "missing /root/.runner; register act_runner before activating service" >&2
exit 1
fi
backup="/root/.runner.bak-$(date +%Y%m%d%H%M%S)"
cp /root/.runner "${backup}"
awk '
/"labels": \[/ {
print " \"labels\": ["
print " \"self-hosted:host\","
print " \"haskelseed:host\","
print " \"linux:host\","
print " \"linux_amd64:host\","
print " \"x86_64:host\","
print " \"container-build:host\","
print " \"registry-publish:host\""
in_labels = 1
next
}
in_labels && /]/ {
print " ],"
in_labels = 0
next
}
!in_labels { print }
' /root/.runner > /root/.runner.tmp
mv /root/.runner.tmp /root/.runner
chmod 0644 /root/.runner
install -m 0755 "${REMOTE_SERVICE_TMP}" /etc/init.d/act_runner
rm -f "${REMOTE_SERVICE_TMP}"
rc-update add act_runner default >/dev/null 2>&1 || true
rc-service act_runner restart
echo "runner_backup=${backup}"
echo "runner_labels:"
sed -n '8,24p' /root/.runner
echo "service_status:"
rc-service act_runner status || true
echo "runner_process:"
pgrep -a act_runner || true
REMOTE