-
Notifications
You must be signed in to change notification settings - Fork 221
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,17 +2,18 @@ | |||||
|
||||||
# Copyright (c) 2021-2024 tteck | ||||||
# Author: tteck (tteckster) | ||||||
# irish1986 (irish1986) | ||||||
# License: MIT | ||||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE | ||||||
|
||||||
function header_info { | ||||||
clear | ||||||
cat <<"EOF" | ||||||
__ ____ __ ___ ___ ____ __ __ _ ____ ___ | ||||||
/ / / / /_ __ ______ / /___ __ |__ \|__ \ / __ \/ // / | | / / |/ / | ||||||
/ / / / __ \/ / / / __ \/ __/ / / / __/ /__/ / / / / / // /_ | | / / /|_/ / | ||||||
/ /_/ / /_/ / /_/ / / / / /_/ /_/ / / __// __/_/ /_/ /__ __/ | |/ / / / / | ||||||
\____/_.___/\__,_/_/ /_/\__/\__,_/ /____/____(_)____/ /_/ |___/_/ /_/ | ||||||
__ ____ __ _ ____ ___ | ||||||
/ / / / /_ __ ______ / /___ __ | | / / |/ / | ||||||
/ / / / __ \/ / / / __ \/ __/ / / / | | / / /|_/ / | ||||||
/ /_/ / /_/ / /_/ / / / / /_/ /_/ / | |/ / / / / | ||||||
\____/_.___/\__,_/_/ /_/\__/\__,_/ |___/_/ /_/ | ||||||
EOF | ||||||
} | ||||||
|
@@ -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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
NOBLE="noble" | ||||||
JAMMY="jammy" | ||||||
FOCAL="focal" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
YW=$(echo "\033[33m") | ||||||
BL=$(echo "\033[36m") | ||||||
HA=$(echo "\033[1;34m") | ||||||
|
@@ -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 | ||||||
|
@@ -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}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" | ||||||
|
@@ -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 \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
consistent with LXC |
||||||
"${ORACULAR}" "oracular " OFF \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"${NOBLE}" "noble " ON \ | ||||||
"${JAMMY}" "jammy " OFF \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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 | ||||||
|
@@ -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}" | ||||||
|
@@ -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 | ||||||
|
@@ -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 | ||||||
|
@@ -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/☕-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" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.