Initial Commit
This commit is contained in:
parent
7a197e3841
commit
3ef1445893
@ -1,47 +1,91 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ____ _ _
|
# ____ _ _
|
||||||
#/ ___|| |_| |__ ___ _ __ ___
|
#/ ___|| |_| |__ ___ _ __ ___
|
||||||
#\___ \| __| '_ \ / _ \| '_ \ / _ \
|
#\___ \| __| '_ \ / _ \| '_ \ / _ \
|
||||||
# ___) | |_| | | | (_) | |_) | __/
|
# ___) | |_| | | | (_) | |_) | __/
|
||||||
#|____/ \__|_| |_|\___/| .__/ \___|
|
#|____/ \__|_| |_|\___/| .__/ \___|
|
||||||
# |_|
|
# |_|
|
||||||
#
|
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Debian 12 (bookworm)
|
# Debian 12 (bookworm)
|
||||||
distro_url="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2"
|
distro_url="https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2"
|
||||||
|
|
||||||
filename="proxmox_cloudinit"
|
filename="proxmox_cloudinit"
|
||||||
|
|
||||||
wget -q "$distro_url" -O "$filename.${file##*.}"
|
wget -q "$distro_url" -O "$filename.${file##*.}"
|
||||||
|
|
||||||
file="$filename.${file##*.}"
|
file="$filename.${file##*.}"
|
||||||
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
NEXTID=$(pvesh get /cluster/nextid)
|
||||||
vm_id=$NEXTID
|
vm_id=$NEXTID
|
||||||
|
|
||||||
echo "What is the VM name?"
|
vm_name="debian"
|
||||||
read -p "Enter your choice: " vm_name
|
vm_ram=2048
|
||||||
qm create $vm_id --name $vm_name --net0 virtio,bridge=vmbr0 >/dev/null
|
vm_core=2
|
||||||
|
username="test"
|
||||||
|
password="changeme"
|
||||||
|
ip4="dhcp"
|
||||||
|
ip6="dhcp"
|
||||||
|
balloon=0
|
||||||
|
onboot=0
|
||||||
|
tablet=0
|
||||||
|
agent_enabled=1
|
||||||
|
hdd_size=10
|
||||||
|
start_now=0
|
||||||
|
|
||||||
|
function display_usage {
|
||||||
|
echo "Usage: bash debian [OPTIONS] "
|
||||||
|
echo "Options: "
|
||||||
|
echo " --name NAME Set the Name for the VM"
|
||||||
|
echo " --ram RAM Set the RAM size for the VM"
|
||||||
|
echo " --core CORE Set the number of CPU cores for the VM"
|
||||||
|
echo " --username USERNAME Set the username for the VM"
|
||||||
|
echo " --password PASSWORD Set the password for the VM"
|
||||||
|
echo " --ip4 IP_ADDRESS Set the IPv4 address for the VM (use 'dhcp' for DHCP)"
|
||||||
|
echo " --ip6 IP_ADDRESS Set the IPv6 address for the VM (use 'dhcp' for DHCP)"
|
||||||
|
echo " --balloon BALLOON Set the balloon value for the VM"
|
||||||
|
echo " --onboot ONBOOT Set the onboot value for the VM"
|
||||||
|
echo " --tablet TABLET Set the tablet value for the VM"
|
||||||
|
echo " --agent-enabled AGENT Set the agent enabled value for the VM"
|
||||||
|
echo " --hdd-size HDD_SIZE Set the size of the VMs HDD in GB"
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--name) vm_name="$2"; shift ;;
|
||||||
|
--ram) vm_ram="$2"; shift ;;
|
||||||
|
--core) vm_core="$2"; shift ;;
|
||||||
|
--username) username="$2"; shift ;;
|
||||||
|
--password) password="$2"; shift ;;
|
||||||
|
--ip4) ip4="$2"; shift ;;
|
||||||
|
--ip6) ip6="$2"; shift ;;
|
||||||
|
--balloon) balloon="$2"; shift ;;
|
||||||
|
--autoboot) onboot="$2"; shift ;;
|
||||||
|
--tablet) tablet="$2"; shift ;;
|
||||||
|
--agent-enabled) agent_enabled="$2"; shift ;;
|
||||||
|
--hdd-size) hdd_size="$2"; shift ;;
|
||||||
|
*) echo "Unknown option: $1"; display_usage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
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 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 --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 --ide2 local-lvm:cloudinit >/dev/null
|
||||||
qm set $vm_id --boot c --bootdisk scsi0 >/dev/null
|
qm set $vm_id --boot c --bootdisk scsi0 >/dev/null
|
||||||
qm set $vm_id --memory 2048 >/dev/null
|
|
||||||
qm set $vm_id --balloon 0 >/dev/null
|
|
||||||
qm set $vm_id --onboot 0 >/dev/null
|
|
||||||
qm set $vm_id --cores 2 >/dev/null
|
|
||||||
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 --serial0 socket --vga serial0 >/dev/null
|
||||||
qm set $vm_id --ipconfig0 ip=dhcp,ip6=dhcp >/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
|
||||||
|
|
||||||
echo "What is the Username for the VM?"
|
if start_now == "y"; do
|
||||||
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() {
|
if [ $start_now -eq 1 ]; then
|
||||||
qm template $vm_id >/dev/null
|
qm start $vm_id
|
||||||
}
|
fi
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ____ _ _
|
# ____ _ _
|
||||||
#/ ___|| |_| |__ ___ _ __ ___
|
#/ ___|| |_| |__ ___ _ __ ___
|
||||||
#\___ \| __| '_ \ / _ \| '_ \ / _ \
|
#\___ \| __| '_ \ / _ \| '_ \ / _ \
|
||||||
# ___) | |_| | | | (_) | |_) | __/
|
# ___) | |_| | | | (_) | |_) | __/
|
||||||
@ -9,19 +9,21 @@ clear
|
|||||||
|
|
||||||
# Ubuntu Server 22.04 (jammy)
|
# Ubuntu Server 22.04 (jammy)
|
||||||
distro_url="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
|
distro_url="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
|
||||||
|
|
||||||
filename="proxmox_cloudinit"
|
filename="proxmox_cloudinit"
|
||||||
|
|
||||||
wget -q "$distro_url" -O "$filename.${file##*.}"
|
wget -q "$distro_url" -O "$filename.${file##*.}"
|
||||||
|
|
||||||
file="$filename.${file##*.}"
|
file="$filename.${file##*.}"
|
||||||
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
NEXTID=$(pvesh get /cluster/nextid)
|
||||||
|
|
||||||
vm_id=$NEXTID
|
vm_id=$NEXTID
|
||||||
vm_name="ubuntu"
|
|
||||||
|
vm_name="debian"
|
||||||
vm_ram=2048
|
vm_ram=2048
|
||||||
vm_core=2
|
vm_core=2
|
||||||
username="admin"
|
username="test"
|
||||||
password=admin
|
password="changeme"
|
||||||
ip4="dhcp"
|
ip4="dhcp"
|
||||||
ip6="dhcp"
|
ip6="dhcp"
|
||||||
balloon=0
|
balloon=0
|
||||||
@ -29,6 +31,43 @@ onboot=0
|
|||||||
tablet=0
|
tablet=0
|
||||||
agent_enabled=1
|
agent_enabled=1
|
||||||
hdd_size=10
|
hdd_size=10
|
||||||
|
start_now=0
|
||||||
|
|
||||||
|
function display_usage {
|
||||||
|
echo "Usage: bash debian [OPTIONS] "
|
||||||
|
echo "Options: "
|
||||||
|
echo " --name NAME Set the Name for the VM"
|
||||||
|
echo " --ram RAM Set the RAM size for the VM"
|
||||||
|
echo " --core CORE Set the number of CPU cores for the VM"
|
||||||
|
echo " --username USERNAME Set the username for the VM"
|
||||||
|
echo " --password PASSWORD Set the password for the VM"
|
||||||
|
echo " --ip4 IP_ADDRESS Set the IPv4 address for the VM (use 'dhcp' for DHCP)"
|
||||||
|
echo " --ip6 IP_ADDRESS Set the IPv6 address for the VM (use 'dhcp' for DHCP)"
|
||||||
|
echo " --balloon BALLOON Set the balloon value for the VM"
|
||||||
|
echo " --onboot ONBOOT Set the onboot value for the VM"
|
||||||
|
echo " --tablet TABLET Set the tablet value for the VM"
|
||||||
|
echo " --agent-enabled AGENT Set the agent enabled value for the VM"
|
||||||
|
echo " --hdd-size HDD_SIZE Set the size of the VMs HDD in GB"
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
--name) vm_name="$2"; shift ;;
|
||||||
|
--ram) vm_ram="$2"; shift ;;
|
||||||
|
--core) vm_core="$2"; shift ;;
|
||||||
|
--username) username="$2"; shift ;;
|
||||||
|
--password) password="$2"; shift ;;
|
||||||
|
--ip4) ip4="$2"; shift ;;
|
||||||
|
--ip6) ip6="$2"; shift ;;
|
||||||
|
--balloon) balloon="$2"; shift ;;
|
||||||
|
--autoboot) onboot="$2"; shift ;;
|
||||||
|
--tablet) tablet="$2"; shift ;;
|
||||||
|
--agent-enabled) agent_enabled="$2"; shift ;;
|
||||||
|
--hdd-size) hdd_size="$2"; shift ;;
|
||||||
|
*) echo "Unknown option: $1"; display_usage; exit 1 ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
qm create $vm_id --name $vm_name --memory $vm_ram --core $vm_core --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 importdisk $vm_id $file local-lvm >/dev/null
|
||||||
@ -41,5 +80,12 @@ qm set $vm_id --onboot $onboot >/dev/null
|
|||||||
qm set $vm_id --tablet $tablet >/dev/null
|
qm set $vm_id --tablet $tablet >/dev/null
|
||||||
qm set $vm_id --agent enabled=$agent_enabled >/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 --ipconfig0 ip=$ip4,ip6=$ip6 >/dev/null
|
||||||
#qm set $vm_id --ciuser "$username" --cipassword "$password" >/dev/null
|
qm set $vm_id --ciuser "$username" --cipassword "$password" >/dev/null
|
||||||
qm resize $vm_id scsi0 +"$hdd_size"G >/dev/null
|
qm resize $vm_id scsi0 +"$hdd_size"G >/dev/null
|
||||||
|
|
||||||
|
if start_now == "y"; do
|
||||||
|
|
||||||
|
|
||||||
|
if [ $start_now -eq 1 ]; then
|
||||||
|
qm start $vm_id
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user