forgejo-runner-pve-ubuntu-l.../clone-and-register.sh
2024-07-27 10:18:41 +02:00

32 lines
657 B
Bash
Executable file

#!/bin/sh
#
# Clone the template VM and register the runner with Forgejo
#
if [ $# -ne 3 ]; then
echo "usage: $0 vmid name registration-token"
exit 64
fi
set -e
vm_id="$1"
vm_name="$2"
token="$3"
qm clone 9042 ${vm_id} --full true --name "${vm_name}"
qm set ${vm_id} --ipconfig0 ip=172.31.17.203/25,gw=172.31.17.129
qm start ${vm_id}
while :; do
qm agent ${vm_id} ping && break
echo "waiting for VM ${vm_id} to complete boot..."
sleep 10
done
echo "VM ${vm_id} started, trying to register runner..."
qm guest exec ${vm_id} -- sudo -iu forgejo-runner register-forgejo-runner "${token}"
qm guest exec ${vm_id} -- systemctl restart forgejo-runner