#!/bin/bash # Description: This simple Scripts creates an Virtualmachine on Proxmox, with the Qemu-Cli. # Usage: Just Execute the script, it's a guided Script (chmod +x CreateCloudInitVM.sh && ./ CreateCloudInitVM.sh) # # Creator: Janic Joël Voser, Mettmenstetten - CH # Date of Creation: 03.12.2021 # # Active Maintainer: Janic Joël Voser # Date of Last Maintenance: 03.12.2021 # # Current State: Development # Version: 0.2.0 # Version History: # v0.0.1 - Basic Script Structure # v0.1.0 - Get the User input # v0.2.0 - Gather Virtual Machine ID # Planned Features: # - [ ] Guided VM Creation # - [ ] Image Download URL # - [ ] Instant VM-Start after Creation # - [ ] Image Selection # - [X] VM-ID check # Global Conigurable Variables # Global Constants # Functions function gather_vmid { echo "Already used IDs" qm list | tr -s ' ' | cut -d ' ' -f 2,3 echo "Enter the new ID of your Virtual Machine (It must be unused)" read VM_ID i=0 readarray -t vmid_array < <(qm list | tail -n +2 | tr -s ' ' | cut -d ' ' -f 2) if [[ "${vmid_array[*]}" =~ "$VM_ID" ]]; then echo "Your selected Virtual Machine ID is already in use, choose an other ID" gather_vmid fi } function get_user_input { gather_vmid } # Main Script get_user_input # Debug