v0.2.0 - Gather Virtual Machine ID
This commit is contained in:
		@@ -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
 | 
			
		||||
@@ -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
 | 
			
		||||
		Reference in New Issue
	
	Block a user