From f41ba1fbed91b29fa4a976f8822b78dd81b4f590 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Jan 2024 03:52:19 +0200 Subject: [PATCH] Added default vga --- Makefile | 39 +++++++++++++++++++++ REFENCES.md | 1 + create-proxmox-cloudinit-images.sh | 54 +++++++++++++++++++++++++----- flags/.placeholder | 0 update-alma-gpg.sh | 1 + 5 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 Makefile create mode 100644 REFENCES.md create mode 100644 flags/.placeholder create mode 100644 update-alma-gpg.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..de744c1 --- /dev/null +++ b/Makefile @@ -0,0 +1,39 @@ +all: + echo OK + +enable-alma-8: + touch flags/alma-8 + +enable-alma-9: + touch flags/alma-9 + +enable-debian-12: + touch flags/debian-12 + +enable-ubuntu-2204: + touch flags/ubuntu-2204 + +enable-all: enable-alma-8 enable-alma-9 enable-debian-12 enable-ubuntu-2204 + +cleanup-flags: + rm -fv flags/* + +create: + bash create-proxmox-cloudinit-images.sh + +create-all: enable-all create + +destroy-debian-12: + qm destroy 9000 + +destroy-alma-8: + qm destroy 9001 + +destroy-alma-9: + qm destroy 9002 + +destroy-ubuntu2204: + qm destroy 9003 + +destroy-all: destroy-debian-12 destroy-alma-8 destroy-alma-9 destroy-ubuntu2204 + diff --git a/REFENCES.md b/REFENCES.md new file mode 100644 index 0000000..bb58ca6 --- /dev/null +++ b/REFENCES.md @@ -0,0 +1 @@ +* diff --git a/create-proxmox-cloudinit-images.sh b/create-proxmox-cloudinit-images.sh index c282a8f..cdb7b4c 100755 --- a/create-proxmox-cloudinit-images.sh +++ b/create-proxmox-cloudinit-images.sh @@ -20,10 +20,11 @@ function createImage() { apt install -y libguestfs-tools case "${IMAGE_TYPE}" in deb*|ubuntu*) - virt-customize -a ${IMAGE_FILE} --install qemu-guest-agent + virt-customize -v -a ${IMAGE_FILE} --install qemu-guest-agent ;; alma*|rhel*|centos*) - virt-customize -a ${IMAGE_FILE} --install qemu-guest-agent + virt-customize -v -a ${IMAGE_FILE} --commands-from-file + virt-customize -v -a ${IMAGE_FILE} --install qemu-guest-agent ;; *) echo "Unknown OS type" @@ -31,13 +32,41 @@ function createImage() { esac fi + case "${IMAGE_TYPE}" in + deb*|ubuntu*) + DISPLAY_TYPE="serial" + + ;; + alma*|rhel*|centos*) + DISPLAY_TYPE="default" + + ;; + *) + DISPLAY_TYPE="default" + echo "Unknown OS type" + ;; + esac + qm create ${IMAGE_ID} --name "${IMAGE_NAME}" --memory ${IMAGE_RAM} --cores ${IMAGE_CORES} \ - --net0 virtio,bridge=vmbr0 + --net0 virtio,bridge=vmbr0 qm importdisk ${IMAGE_ID} ${IMAGE_FILE} ${IMAGE_STORE} + qm set ${IMAGE_ID} --cpu cputype=x86-64-v2 qm set ${IMAGE_ID} --scsihw virtio-scsi-pci --scsi0 ${IMAGE_STORE}:vm-${IMAGE_ID}-disk-0 qm set ${IMAGE_ID} --boot c --bootdisk scsi0 qm set ${IMAGE_ID} --ide2 ${IMAGE_STORE}:cloudinit - qm set ${IMAGE_ID} --serial0 socket --vga serial0 + + case "${DISPLAY_TYPE}" in + serial) + qm set ${IMAGE_ID} --serial0 socket --vga serial0 + ;; + default) + qm set ${IMAGE_ID} --vga std + ;; + *) + qm set ${IMAGE_ID} --vga std + ;; + esac + qm set ${IMAGE_ID} --agent enabled=1 rm -vf "${IMAGE_FILE}" @@ -93,10 +122,12 @@ then DEBIAN_12_IMAGE_URL="${DEBIAN_12_LOCAL_IMAGE_URL}" fi +if [ -f "flags/debian-12" ] +then createImage "${DEBIAN_12_IMAGE_URL}" "${DEBIAN_12_TEMPLATE_ID}" \ "${DEBIAN_12_IMAGE_FILENAME}" "${DEBIAN_12_TEMPLATE_NAME}" \ "${DEBIAN_12_TEMPLATE_RAM}" "${DEBIAN_12_TEMPLATE_CORES}" "${DEBIAN_12_TEMPLATE_STORE}" "deb" - +fi ## AlmaLinux 8 ALMA_8_IMAGE_URL="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-latest.x86_64.qcow2" @@ -113,10 +144,12 @@ then ALMA_8_IMAGE_URL="${ALMA_8_LOCAL_IMAGE_URL}" fi +if [ -f "flags/alma-8" ] +then createImage "${ALMA_8_IMAGE_URL}" "${ALMA_8_TEMPLATE_ID}" \ "${ALMA_8_IMAGE_FILENAME}" "${ALMA_8_TEMPLATE_NAME}" \ "${ALMA_8_TEMPLATE_RAM}" "${ALMA_8_TEMPLATE_CORES}" "${ALMA_8_TEMPLATE_STORE}" "alma" - +fi ## AlmaLinux 9 ALMA_9_IMAGE_URL="https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-latest.x86_64.qcow2" @@ -133,10 +166,13 @@ then ALMA_9_IMAGE_URL="${ALMA_9_LOCAL_IMAGE_URL}" fi +if [ -f "flags/alma-9" ] +then + createImage "${ALMA_9_IMAGE_URL}" "${ALMA_9_TEMPLATE_ID}" \ "${ALMA_9_IMAGE_FILENAME}" "${ALMA_9_TEMPLATE_NAME}" \ "${ALMA_9_TEMPLATE_RAM}" "${ALMA_9_TEMPLATE_CORES}" "${ALMA_9_TEMPLATE_STORE}" "alma" - +fi ## Ubuntu 22.04 UBUNTU_2204_IMAGE_URL="https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64-disk-kvm.img" @@ -153,8 +189,10 @@ then UBUNTU_2204_IMAGE_URL="${UBUNTU_2204_LOCAL_IMAGE_URL}" fi +if [ -f "flags/ubuntu-2204" ] +then createImage "${UBUNTU_2204_IMAGE_URL}" "${UBUNTU_2204_TEMPLATE_ID}" \ "${UBUNTU_2204_IMAGE_FILENAME}" "${UBUNTU_2204_TEMPLATE_NAME}" \ "${UBUNTU_2204_TEMPLATE_RAM}" "${UBUNTU_2204_TEMPLATE_CORES}" "${UBUNTU_2204_TEMPLATE_STORE}" "alma" - +fi diff --git a/flags/.placeholder b/flags/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/update-alma-gpg.sh b/update-alma-gpg.sh new file mode 100644 index 0000000..44ab613 --- /dev/null +++ b/update-alma-gpg.sh @@ -0,0 +1 @@ +rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux