#!/bin/sh # # Build a Proxmox template VM from a qcow image based on the Github # runner-images KVM image for ubuntu-24.04, with the forgejo-runner added. # set -e builder_host=forgejo-runner-builder builder_script=build-github-runner-kvm-ubuntu-latest-qcow.sh runner_image=github-runner-image-ubuntu-24.04.qcow2 forgejo_runner_url=https://code.forgejo.org/forgejo/runner/releases/download/v3.5.0/forgejo-runner-3.5.0-linux-amd64 vm_id=9042 vm_name=template-forgejo-runner vm_bridge=vmbr4 vm_storage="local-zfs" #ssh ${builder_host} sudo sh <${builder_script} #scp ${builder_host}:${runner_image} . #wget --output-document=forgejo_runner ${forgejo_runner_url} wget -N https://git.hamburg.ccc.de/CCCHH/infrastructure-authorized-keys/raw/branch/trunk/authorized_keys virt-customize -a ${runner_image} \ --update \ --install qemu-guest-agent \ --run-command 'systemctl enable fstrim.timer' \ --edit '/etc/passwd:$_ = "" if /^forgejo:/' \ --edit '/etc/group:$_ = "" if /^forgejo:/' \ --run-command 'useradd --groups docker --create-home --shell /bin/bash --uid 2000 --user-group forgejo' \ --copy-in forgejo_runner:/usr/local/bin \ --run-command 'chown root:bin /usr/local/bin/forgejo_runner' \ --run-command 'chmod 0555 /usr/local/bin/forgejo_runner' \ --copy-in forgejo-runner.service:/etc/systemd/system \ qm destroy ${vm_id} || true qm create ${vm_id} --name "${vm_name}" --memory 2048 --net0 virtio,bridge=${vm_bridge} qm importdisk ${vm_id} ${runner_image} ${vm_storage} qm set ${vm_id} --scsihw virtio-scsi-pci --scsi0 ${vm_storage}:vm-${vm_id}-disk-0,ssd=1,discard=on qm set ${vm_id} --ide2 ${vm_storage}:cloudinit qm set ${vm_id} --boot c --bootdisk scsi0 qm set ${vm_id} --machine q35 qm set ${vm_id} --ostype l26 qm set ${vm_id} --cpu cputype=host qm set ${vm_id} --cores 2 qm set ${vm_id} --serial0 socket --vga serial0 qm set ${vm_id} --agent 1,fstrim_cloned_disks=1 qm set ${vm_id} --ciuser chaos qm set ${vm_id} --sshkeys ./authorized_keys qm set ${vm_id} --ipconfig0 ip=dhcp qm set ${vm_id} --tags ubuntu24.04 qm cloudinit update ${vm_id} qm template ${vm_id} echo "*** Done ***"