Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Ubuntu VM script #269

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions json/ubuntu2204-vm.json → json/ubuntu-vm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "Ubuntu 22.04",
"slug": "ubuntu2204-vm",
"name": "Ubuntu",
"slug": "ubuntu-vm",
"categories": [
9
],
"date_created": "2024-05-02",
"date_created": "2024-11-15",
"type": "vm",
"updateable": false,
"privileged": false,
Expand All @@ -16,7 +16,7 @@
"install_methods": [
{
"type": "default",
"script": "vm/ubuntu2204-vm.sh",
"script": "vm/ubuntu-vm.sh",
"resources": {
"cpu": "2",
"ram": "2048",
Expand Down
34 changes: 0 additions & 34 deletions json/ubuntu2404-vm.json

This file was deleted.

54 changes: 36 additions & 18 deletions vm/ubuntu2204-vm.sh → vm/ubuntu-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

# Copyright (c) 2021-2024 tteck
# Author: tteck (tteckster)
# irish1986 (irish1986)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# irish1986 (irish1986)
# Co-Author: irish1986 (irish1986)

# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE

function header_info {
clear
cat <<"EOF"
__ ____ __ ___ ___ ____ __ __ _ ____ ___
/ / / / /_ __ ______ / /___ __ |__ \|__ \ / __ \/ // / | | / / |/ /
/ / / / __ \/ / / / __ \/ __/ / / / __/ /__/ / / / / / // /_ | | / / /|_/ /
/ /_/ / /_/ / /_/ / / / / /_/ /_/ / / __// __/_/ /_/ /__ __/ | |/ / / / /
\____/_.___/\__,_/_/ /_/\__/\__,_/ /____/____(_)____/ /_/ |___/_/ /_/
__ ____ __ _ ____ ___
/ / / / /_ __ ______ / /___ __ | | / / |/ /
/ / / / __ \/ / / / __ \/ __/ / / / | | / / /|_/ /
/ /_/ / /_/ / /_/ / / / / /_/ /_/ / | |/ / / / /
\____/_.___/\__,_/_/ /_/\__/\__,_/ |___/_/ /_/
EOF
}
Expand All @@ -21,6 +22,11 @@ echo -e "\n Loading..."
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
NEXTID=$(pvesh get /cluster/nextid)

ORACULAR="oracular"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ORACULAR="oracular"

NOBLE="noble"
JAMMY="jammy"
FOCAL="focal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FOCAL="focal"


YW=$(echo "\033[33m")
BL=$(echo "\033[36m")
HA=$(echo "\033[1;34m")
Expand Down Expand Up @@ -60,7 +66,7 @@ function cleanup() {

TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 22.04 VM" --yesno "This will create a New Ubuntu 22.04 VM. Proceed?" 10 58; then
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu VM" --yesno "This will create a New Ubuntu VM. Proceed?" 10 58; then
:
else
header_info && echo -e "⚠ User exited script \n" && exit
Expand Down Expand Up @@ -130,11 +136,12 @@ function exit-script() {
}

function default_settings() {
RELEASE="${NOBLE}"
VMID="$NEXTID"
FORMAT=",efitype=4m"
MACHINE=""
DISK_CACHE=""
HN="ubuntu"
HN="ubuntu-${NOBLE}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to hostname if you choose jammy in advanced settings? you have to manually fix it?

CPU_TYPE=""
CORE_COUNT="2"
RAM_SIZE="2048"
Expand All @@ -155,10 +162,21 @@ function default_settings() {
echo -e "${DGN}Using VLAN: ${BGN}Default${CL}"
echo -e "${DGN}Using Interface MTU Size: ${BGN}Default${CL}"
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
echo -e "${BL}Creating an Ubuntu 22.04 VM using the above default settings${CL}"
echo -e "${BL}Creating an Ubuntu VM using the above default settings${CL}"
}

function advanced_settings() {
if RELEASE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu RELEASE" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if RELEASE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu RELEASE" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
if RELEASE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UBUNTU VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 2 \

consistent with LXC

"${ORACULAR}" "oracular " OFF \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"${ORACULAR}" "oracular " OFF \

"${NOBLE}" "noble " ON \
"${JAMMY}" "jammy " OFF \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move jammy option above noble, to be consistent with LXC

"${FOCAL}" "focal " OFF \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"${FOCAL}" "focal " OFF \

3>&1 1>&2 2>&3); then
echo -e "${DGN}Using Ubuntu Version: ${BGN}$RELEASE${CL}"
else
exit-script
fi

while true; do
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
if [ -z "$VMID" ]; then
Expand Down Expand Up @@ -314,8 +332,8 @@ function advanced_settings() {
START_VM="no"
fi

if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu 22.04 VM?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating an Ubuntu 22.04 VM using the above advanced settings${CL}"
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create an Ubuntu VM?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating an Ubuntu VM using the above advanced settings${CL}"
else
header_info
echo -e "${RD}Using Advanced Settings${CL}"
Expand Down Expand Up @@ -369,8 +387,8 @@ else
fi
msg_ok "Using ${CL}${BL}$STORAGE${CL} ${GN}for Storage Location."
msg_ok "Virtual Machine ID is ${CL}${BL}$VMID${CL}."
msg_info "Retrieving the URL for the Ubuntu 22.04 Disk Image"
URL=https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
msg_info "Retrieving the URL for the Ubuntu ${RELEASE} Disk Image"
URL=https://cloud-images.ubuntu.com/${RELEASE}/current/${RELEASE}-server-cloudimg-amd64.img
sleep 2
msg_ok "${CL}${BL}${URL}${CL}"
wget -q --show-progress $URL
Expand Down Expand Up @@ -400,7 +418,7 @@ for i in {0,1}; do
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
done

msg_info "Creating a Ubuntu 22.04 VM"
msg_info "Creating a Ubuntu ${RELEASE} VM"
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
-name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
Expand All @@ -413,16 +431,16 @@ qm set $VMID \
-serial0 socket \
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
# Ubuntu 22.04 VM
# Ubuntu ${RELEASE} VM
<a href='https://ko-fi.com/D1D7EP4GF'><img src='https://img.shields.io/badge/&#x2615;-Buy me a coffee-blue' /></a>
</div>" >/dev/null
msg_ok "Created a Ubuntu 22.04 VM ${CL}${BL}(${HN})"
msg_ok "Created a Ubuntu VM ${CL}${BL}(${HN})"
if [ "$START_VM" == "yes" ]; then
msg_info "Starting Ubuntu 22.04 VM"
msg_info "Starting Ubuntu ${RELEASE} VM"
qm start $VMID
msg_ok "Started Ubuntu 22.04 VM"
msg_ok "Started Ubuntu ${RELEASE} VM"
fi
msg_ok "Completed Successfully!\n"
echo -e "Setup Cloud-Init before starting \n
More info at https://github.com/tteck/Proxmox/discussions/2072 \n"
More info at https://github.com/community-scripts/ProxmoxVE/discussions/268 \n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
More info at https://github.com/community-scripts/ProxmoxVE/discussions/268 \n"
More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n"

Loading