2021-12-03 08:05:29 +01:00
|
|
|
#!/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
|
2021-12-03 08:57:32 +01:00
|
|
|
# Version: 0.2.0
|
2021-12-03 08:05:29 +01:00
|
|
|
# Version History:
|
|
|
|
# v0.0.1 - Basic Script Structure
|
2021-12-03 08:57:32 +01:00
|
|
|
# v0.1.0 - Get the User input
|
|
|
|
# v0.2.0 - Gather Virtual Machine ID
|
2021-12-03 08:05:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
# Planned Features:
|
|
|
|
# - [ ] Guided VM Creation
|
|
|
|
# - [ ] Image Download URL
|
|
|
|
# - [ ] Instant VM-Start after Creation
|
2021-12-03 08:57:32 +01:00
|
|
|
# - [ ] Image Selection
|
|
|
|
# - [X] VM-ID check
|
2021-12-03 08:05:29 +01:00
|
|
|
|
|
|
|
# Global Conigurable Variables
|
|
|
|
|
2021-12-03 08:57:32 +01:00
|
|
|
# Global Constants
|
2021-12-03 08:05:29 +01:00
|
|
|
|
|
|
|
# Functions
|
2021-12-03 08:57:32 +01:00
|
|
|
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
|
2021-12-03 08:05:29 +01:00
|
|
|
|
2021-12-03 08:57:32 +01:00
|
|
|
}
|
|
|
|
function get_user_input {
|
|
|
|
gather_vmid
|
|
|
|
|
|
|
|
}
|
2021-12-03 08:05:29 +01:00
|
|
|
# Main Script
|
2021-12-03 08:57:32 +01:00
|
|
|
get_user_input
|
2021-12-03 08:05:29 +01:00
|
|
|
|
|
|
|
# Debug
|