Created
July 18, 2025 20:40
-
-
Save Alee14/e3c04da95a78209006c590731bccc7f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Enter URL for the cloud image" | |
read cloudurl | |
wget "$cloudurl" | |
if [ $? -ne 0 ]; then | |
echo "Download failed. Exiting." | |
exit 1 | |
fi | |
filename=$(basename $cloudurl) | |
echo Downloaded $filename | |
echo "Enter the VMID for the cloud template" | |
read -p "> " vmid | |
echo "Enter the VM name of the template" | |
read -p "> " vmname | |
qm create $vmid --name $vmname -net0 virtio,bridge=vmbr0 --ostype l26 --tablet 0 --cpu host --agent 1 --cores 2 --memory 1024 --scsihw virtio-scsi-pci | |
if [ $? -ne 0 ]; then | |
echo "Failed to create VM. Exiting." | |
exit 1 | |
fi | |
echo "Which storage pool do you want to use?" | |
pvesm status | |
read -p "> " storage | |
echo "Importing disk" | |
qm importdisk $vmid $filename $storage --format qcow2 | |
#qm set $vmid --scsi0 $storage:0,import-from=$filename | |
if [ $? -ne 0 ]; then | |
echo "Failed setting up disk. Exiting." | |
exit 1 | |
fi | |
#echo "Changing boot order" | |
#qm set $vmid --boot order=virtio0 | |
echo "Removing current file" | |
rm $filename | |
echo "Adding cloudinit" | |
qm set $vmid --ide2 $storage:cloudinit | |
echo "Setting display to serial" | |
qm set $vmid --serial0 socket --vga serial0 | |
echo "VM setup complete. Add the disk, then enter cloudinit credentials manually." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment