diff --git a/README.md b/README.md index eccef83..551801d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Just Execute the script, it's a guided Script (chmod +x CreateCloudInitVM.sh && - [ ] Guided VM Creation - [ ] Image Download URL - [ ] Instant VM-Start after Creation - + - [ ] Image Selection + - [X] VM-ID check # Bookstack Link to general Cloud-Init Information https://bookstack.voser.cloud/books/virtualisierung/chapter/cloud-init \ No newline at end of file diff --git a/Scripts/CreateCloudInitVM.sh b/Scripts/CreateCloudInitVM.sh index 132c0e7..492a9cf 100644 --- a/Scripts/CreateCloudInitVM.sh +++ b/Scripts/CreateCloudInitVM.sh @@ -9,22 +9,43 @@ # Date of Last Maintenance: 03.12.2021 # # Current State: Development -# Version: 0.0.1 +# 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 Constantst +# 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 \ No newline at end of file