Advertisement
ptr727

Untitled

Aug 2nd, 2023
1,215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -e
  4. set -x
  5.  
  6. VM_ID=$1
  7. VM_NAME=$2
  8. VM_TAGS=$3
  9. VM_USER=$4
  10. VM_PASSWORD=$5
  11. VM_DOMAIN=$6
  12. VM_SSH_KEYS=$7
  13. VM_IMAGE=$8
  14.  
  15. qm unlock $VM_ID || true
  16. qm destroy $VM_ID || true
  17. qm create $VM_ID \
  18.     --name $VM_NAME \
  19.     --tags $VM_TAGS \
  20.     --memory 4096 \
  21.     --cores 2 \
  22.     --net0 virtio,bridge=vmbr1 \
  23.     --scsihw virtio-scsi-pci \
  24.     --ciuser $VM_USER \
  25.     --cipassword $VM_PASSWORD \
  26.     --searchdomain $VM_DOMAIN \
  27.     --sshkeys $VM_SSH_KEYS \
  28.     --ipconfig0 ip=dhcp \
  29.     --ostype l26 \
  30.     --agent 1
  31. virt-customize -a $VM_IMAGE --install qemu-guest-agent
  32. qm set $VM_ID --scsi0 vmdata:0,import-from=$VM_IMAGE --boot order=scsi0 --ide2 vmdata:cloudinit
  33. qm resize $VM_ID scsi0 8G
  34. qm template $VM_ID
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement