#!/bin/bash
OSV="12"
export VMCIID="912"
FILE="debian-$OSV-genericcloud-amd64.qcow2"
wget https://cloud.debian.org/images/cloud/bookworm/latest/$FILE
FILETS=$(ls -lh debian-$OSV-genericcloud-amd64.qcow2 | cut -c 24-)
timestamp=$(date)
qm create $VMCIID --name debian$OSV-cloudinit --memory 512 --net0 virtio,bridge=vmbr0 --ostype l26 --agent 1 --protection 0 --tags template
qm importdisk $VMCIID $FILE local --format qcow2
qm set $VMCIID --scsihw virtio-scsi-single --scsi0 local:$VMCIID/vm-$VMCIID-disk-0.qcow2
qm set $VMCIID --boot c --bootdisk scsi0
qm set $VMCIID --ide0 local:cloudinit
qm set $VMCIID --serial0 socket --vga serial0
qm set $VMCIID --description "Created by: cloud$OSV.sh
debian $OSV cloud-init template:
$FILETS
Deployed: $timestamp"
qm template $VMCIID