forgejo-runner-pve-ubuntu-l.../clone-and-register.sh

32 lines
657 B
Bash
Raw Normal View History

2024-07-27 09:58:18 +02:00
#!/bin/sh
#
# Clone the template VM and register the runner with Forgejo
#
2024-07-27 10:18:41 +02:00
if [ $# -ne 3 ]; then
echo "usage: $0 vmid name registration-token"
exit 64
2024-07-27 09:58:18 +02:00
fi
2024-07-27 10:18:41 +02:00
set -e
2024-07-27 09:58:18 +02:00
vm_id="$1"
2024-07-27 10:18:41 +02:00
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
2024-07-27 09:58:18 +02:00
qm start ${vm_id}
while :; do
qm agent ${vm_id} ping && break
echo "waiting for VM ${vm_id} to complete boot..."
sleep 10
done
2024-07-27 10:18:41 +02:00
echo "VM ${vm_id} started, trying to register runner..."
2024-07-27 09:58:18 +02:00
qm guest exec ${vm_id} -- sudo -iu forgejo-runner register-forgejo-runner "${token}"
qm guest exec ${vm_id} -- systemctl restart forgejo-runner