Initial Commit
This commit is contained in:
parent
1546e05b99
commit
7a197e3841
78
VM/Cloud-Init/config.sh
Normal file
78
VM/Cloud-Init/config.sh
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
VMID=100
|
||||
|
||||
# Function definition for send_line_to_vm (assuming it's already defined in the script)
|
||||
|
||||
function send_line_to_vm() {
|
||||
echo -e "${DGN}Sending line: ${YW}$1${CL}"
|
||||
for ((i = 0; i < ${#1}; i++)); do
|
||||
character=${1:i:1}
|
||||
case $character in
|
||||
" ") character="spc" ;;
|
||||
"-") character="minus" ;;
|
||||
"=") character="equal" ;;
|
||||
",") character="comma" ;;
|
||||
".") character="dot" ;;
|
||||
"/") character="slash" ;;
|
||||
"'") character="apostrophe" ;;
|
||||
";") character="semicolon" ;;
|
||||
'\') character="backslash" ;;
|
||||
'`') character="grave_accent" ;;
|
||||
"[") character="bracket_left" ;;
|
||||
"]") character="bracket_right" ;;
|
||||
"_") character="shift-minus" ;;
|
||||
"+") character="shift-equal" ;;
|
||||
"?") character="shift-slash" ;;
|
||||
"<") character="shift-comma" ;;
|
||||
">") character="shift-dot" ;;
|
||||
'"') character="shift-apostrophe" ;;
|
||||
":") character="shift-semicolon" ;;
|
||||
"|") character="shift-backslash" ;;
|
||||
"~") character="shift-grave_accent" ;;
|
||||
"{") character="shift-bracket_left" ;;
|
||||
"}") character="shift-bracket_right" ;;
|
||||
"A") character="shift-a" ;;
|
||||
"B") character="shift-b" ;;
|
||||
"C") character="shift-c" ;;
|
||||
"D") character="shift-d" ;;
|
||||
"E") character="shift-e" ;;
|
||||
"F") character="shift-f" ;;
|
||||
"G") character="shift-g" ;;
|
||||
"H") character="shift-h" ;;
|
||||
"I") character="shift-i" ;;
|
||||
"J") character="shift-j" ;;
|
||||
"K") character="shift-k" ;;
|
||||
"L") character="shift-l" ;;
|
||||
"M") character="shift-m" ;;
|
||||
"N") character="shift-n" ;;
|
||||
"O") character="shift-o" ;;
|
||||
"P") character="shift-p" ;;
|
||||
"Q") character="shift-q" ;;
|
||||
"R") character="shift-r" ;;
|
||||
"S") character="shift-s" ;;
|
||||
"T") character="shift-t" ;;
|
||||
"U") character="shift-u" ;;
|
||||
"V") character="shift-v" ;;
|
||||
"W") character="shift-w" ;;
|
||||
"X") character="shift=x" ;;
|
||||
"Y") character="shift-y" ;;
|
||||
"Z") character="shift-z" ;;
|
||||
"!") character="shift-1" ;;
|
||||
"@") character="shift-2" ;;
|
||||
"#") character="shift-3" ;;
|
||||
'$') character="shift-4" ;;
|
||||
"%") character="shift-5" ;;
|
||||
"^") character="shift-6" ;;
|
||||
"&") character="shift-7" ;;
|
||||
"*") character="shift-8" ;;
|
||||
"(") character="shift-9" ;;
|
||||
")") character="shift-0" ;;
|
||||
esac
|
||||
qm sendkey $VMID "$character"
|
||||
done
|
||||
qm sendkey $VMID ret
|
||||
}
|
||||
|
||||
# Call the function with the desired string as an argument
|
||||
send_line_to_vm "apt-get install -y qemu-guest-agent"
|
@ -14,14 +14,15 @@ distro_url="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-gene
|
||||
filename="proxmox_cloudinit"
|
||||
|
||||
wget -q "$distro_url" -O "$filename.${file##*.}"
|
||||
|
||||
file="$filename.${file##*.}"
|
||||
|
||||
NEXTID=$(pvesh get /cluster/nextid)
|
||||
|
||||
vm_id=$NEXTID
|
||||
vm_name="debian"
|
||||
|
||||
echo "What is the VM name?"
|
||||
read -p "Enter your choice: " vm_name
|
||||
qm create $vm_id --name $vm_name --net0 virtio,bridge=vmbr0 >/dev/null
|
||||
|
||||
qm importdisk $vm_id $file local-lvm >/dev/null
|
||||
qm set $vm_id --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-$vm_id-disk-0 >/dev/null
|
||||
qm set $vm_id --ide2 local-lvm:cloudinit >/dev/null
|
||||
@ -34,7 +35,12 @@ qm set $vm_id --tablet 0 >/dev/null
|
||||
qm set $vm_id --agent enabled=1 >/dev/null
|
||||
qm set $vm_id --serial0 socket --vga serial0 >/dev/null
|
||||
qm set $vm_id --ipconfig0 ip=dhcp,ip6=dhcp >/dev/null
|
||||
qm set $vm_id --ciuser test --cipassword test >/dev/null
|
||||
|
||||
echo "What is the Username for the VM?"
|
||||
read -p "Enter your choice: " username
|
||||
echo "What is the Password for the VM?"
|
||||
read -p "Enter your choice: " password
|
||||
qm set $vm_id --ciuser $username --cipassword $password >/dev/null
|
||||
|
||||
function make_template() {
|
||||
qm template $vm_id >/dev/null
|
||||
|
@ -5,8 +5,6 @@
|
||||
# ___) | |_| | | | (_) | |_) | __/
|
||||
#|____/ \__|_| |_|\___/| .__/ \___|
|
||||
# |_|
|
||||
#
|
||||
|
||||
clear
|
||||
|
||||
# Ubuntu Server 22.04 (jammy)
|
||||
@ -20,27 +18,28 @@ NEXTID=$(pvesh get /cluster/nextid)
|
||||
|
||||
vm_id=$NEXTID
|
||||
vm_name="ubuntu"
|
||||
vm_ram=2048
|
||||
vm_core=2
|
||||
username="admin"
|
||||
password=admin
|
||||
ip4="dhcp"
|
||||
ip6="dhcp"
|
||||
balloon=0
|
||||
onboot=0
|
||||
tablet=0
|
||||
agent_enabled=1
|
||||
hdd_size=10
|
||||
|
||||
qm create $vm_id --memory 2048 --core 2 --name $vm_name --net0 virtio,bridge=vmbr0 >/dev/null
|
||||
qm create $vm_id --name $vm_name --memory $vm_ram --core $vm_core --net0 virtio,bridge=vmbr0 >/dev/null
|
||||
qm importdisk $vm_id $file local-lvm >/dev/null
|
||||
qm set $vm_id --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-$vm_id-disk-0 >/dev/null
|
||||
qm set $vm_id --ide2 local-lvm:cloudinit >/dev/null
|
||||
qm set $vm_id --boot c --bootdisk scsi0 >/dev/null
|
||||
qm set $vm_id --serial0 socket --vga serial0 >/dev/null
|
||||
|
||||
qm set $vm_id --balloon 0 >/dev/null
|
||||
qm set $vm_id --onboot 0 >/dev/null
|
||||
qm set $vm_id --tablet 0 >/dev/null
|
||||
qm set $vm_id --agent enabled=1 >/dev/null
|
||||
qm set $vm_id --ipconfig0 ip=dhcp,ip6=dhcp >/dev/null
|
||||
qm set $vm_id --ciuser test --cipassword test >/dev/null
|
||||
|
||||
# Create a Template
|
||||
function make_template() {
|
||||
qm template $vm_id >/dev/null
|
||||
}
|
||||
|
||||
# Clone the Template
|
||||
function clone_template() {
|
||||
qm clone $vm_id $vm_cloned_id --name $vm_cloned_name --full >/dev/null
|
||||
}
|
||||
qm set $vm_id --balloon $balloon >/dev/null
|
||||
qm set $vm_id --onboot $onboot >/dev/null
|
||||
qm set $vm_id --tablet $tablet >/dev/null
|
||||
qm set $vm_id --agent enabled=$agent_enabled >/dev/null
|
||||
qm set $vm_id --ipconfig0 ip=$ip4,ip6=$ip6 >/dev/null
|
||||
#qm set $vm_id --ciuser "$username" --cipassword "$password" >/dev/null
|
||||
qm resize $vm_id scsi0 +"$hdd_size"G >/dev/null
|
@ -21,5 +21,29 @@ read -p "Enter your choice: " what_storage
|
||||
|
||||
qm importdisk 123 openwrt.raw $what_storage
|
||||
|
||||
echo "What is the VM name?"
|
||||
read -p "Enter your choice: " vm_name
|
||||
qm create $vm_id --memory 2048 --core 2 --name $vm_name --net0 virtio,bridge=vmbr0 >/dev/null
|
||||
|
||||
qm importdisk $vm_id $file local-lvm >/dev/null
|
||||
qm set $vm_id --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-$vm_id-disk-0 >/dev/null
|
||||
qm set $vm_id --ide2 local-lvm:cloudinit >/dev/null
|
||||
qm set $vm_id --boot c --bootdisk scsi0 >/dev/null
|
||||
qm set $vm_id --serial0 socket --vga serial0 >/dev/null
|
||||
|
||||
qm set $vm_id --balloon 0 >/dev/null
|
||||
qm set $vm_id --onboot 0 >/dev/null
|
||||
qm set $vm_id --tablet 0 >/dev/null
|
||||
qm set $vm_id --agent enabled=1 >/dev/null
|
||||
qm set $vm_id --ipconfig0 ip=dhcp,ip6=dhcp >/dev/
|
||||
|
||||
echo "What is the Username?"
|
||||
read -p "Enter your choice: " username
|
||||
echo "What is the Password?"
|
||||
read -p "Enter your choice: " password
|
||||
qm set $vm_id --ciuser $username --cipassword $password >/dev/null
|
||||
|
||||
|
||||
|
||||
# Exit the script.
|
||||
exit 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user