mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-10-08 17:20:27 -04:00
Compare commits
6 Commits
fix/immich
...
MickLesk-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1988243e56 | ||
|
|
84b7ca31e3 | ||
|
|
8876248b54 | ||
|
|
7d2c2205b2 | ||
|
|
ab3f133d06 | ||
|
|
f9148e4fbc |
@@ -567,7 +567,11 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
|
||||
|
||||
### 💾 Core
|
||||
|
||||
- Shared VM helpers: disk import, releases, checksums, first boot, IP by MAC [@MickLesk](https://github.com/MickLesk) ([core#117](https://github.com/community-scripts/core/pull/117))
|
||||
- VM's: run first-boot units without debconf dialogs [@MickLesk](https://github.com/MickLesk) ([core#121](https://github.com/community-scripts/core/pull/121))
|
||||
- Choose the VM keyboard layout and carry the host's timezone into prepared images [@MickLesk](https://github.com/MickLesk) ([core#120](https://github.com/community-scripts/core/pull/120))
|
||||
- Remember a kept cached image until the upstream changes [@MickLesk](https://github.com/MickLesk) ([core#119](https://github.com/community-scripts/core/pull/119))
|
||||
- tools: forge truncated release list [@MickLesk](https://github.com/MickLesk) ([core#118](https://github.com/community-scripts/core/pull/118))
|
||||
- Shared VM helpers: disk import, releases, checksums, first boot, IP by MAC [@MickLesk](https://github.com/MickLesk) ([core#117](https://github.com/community-scripts/core/pull/117))
|
||||
|
||||
## 2026-10-07
|
||||
|
||||
|
||||
129
vm/ubuntu-vm.sh
129
vm/ubuntu-vm.sh
@@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2021-2026 community-scripts ORG
|
||||
# Author: MickLesk (CanbiZ)
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||
|
||||
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main}"
|
||||
COMMUNITY_SCRIPTS_URL="${COMMUNITY_SCRIPTS_URL:-https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main}"
|
||||
source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/pve/vm-core.func")
|
||||
load_functions
|
||||
|
||||
@@ -19,55 +18,51 @@ var_version="26.04"
|
||||
THIN="discard=on,ssd=1,"
|
||||
USE_CLOUD_INIT="no"
|
||||
|
||||
|
||||
set -e
|
||||
set -Eeo pipefail
|
||||
shopt -s inherit_errexit
|
||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||
trap cleanup EXIT
|
||||
trap 'post_update_to_api "failed" "130"' SIGINT
|
||||
trap 'post_update_to_api "failed" "143"' SIGTERM
|
||||
trap 'post_update_to_api "failed" "129"; exit 129' SIGHUP
|
||||
|
||||
vm_preflight
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
pushd "$TEMP_DIR" >/dev/null
|
||||
|
||||
if [[ "${VM_UNATTENDED:-0}" == "1" ]]; then
|
||||
var_version="${VM_OS_VERSION:-$var_version}"
|
||||
elif vm_dialog radiolist "UBUNTU VERSION" "Choose the Ubuntu release to install" --cancel-button Exit-Script 13 60 4 \
|
||||
"26.04" "Ubuntu 26.04 LTS (Resolute)" ON \
|
||||
"25.04" "Ubuntu 25.04 (Plucky)" OFF \
|
||||
"24.04" "Ubuntu 24.04 LTS (Noble)" OFF \
|
||||
"22.04" "Ubuntu 22.04 LTS (Jammy)" OFF; then
|
||||
var_version="$VM_DIALOG_RESULT"
|
||||
else
|
||||
exit_script
|
||||
fi
|
||||
vm_preflight
|
||||
vm_require_tools virt-customize
|
||||
|
||||
case "$var_version" in
|
||||
26.04) UBUNTU_CODENAME="resolute" ;;
|
||||
25.04) UBUNTU_CODENAME="plucky" ;;
|
||||
24.04) UBUNTU_CODENAME="noble" ;;
|
||||
22.04) UBUNTU_CODENAME="jammy" ;;
|
||||
*)
|
||||
msg_error "Unsupported Ubuntu version '${var_version}'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
APP="Ubuntu ${var_version} VM"
|
||||
function select_os() {
|
||||
if [[ -n "${1:-}" ]]; then
|
||||
var_version="$1"
|
||||
elif [[ "${VM_UNATTENDED:-0}" == "1" ]]; then
|
||||
var_version="${VM_OS_VERSION:-$var_version}"
|
||||
elif vm_dialog radiolist "UBUNTU VERSION" "Choose the Ubuntu release to install" --cancel-button Exit-Script 13 60 4 \
|
||||
"26.04" "Ubuntu 26.04 LTS (Resolute)" ON \
|
||||
"24.04" "Ubuntu 24.04 LTS (Noble)" OFF \
|
||||
"22.04" "Ubuntu 22.04 LTS (Jammy)" OFF; then
|
||||
var_version="$VM_DIALOG_RESULT"
|
||||
else
|
||||
exit_script
|
||||
fi
|
||||
|
||||
case "$var_version" in
|
||||
26.04) UBUNTU_CODENAME="resolute" ;;
|
||||
24.04) UBUNTU_CODENAME="noble" ;;
|
||||
22.04) UBUNTU_CODENAME="jammy" ;;
|
||||
*)
|
||||
msg_error "Unsupported Ubuntu version '${var_version}'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
APP="Ubuntu ${var_version}"
|
||||
}
|
||||
|
||||
header_info
|
||||
echo -e "\n Loading..."
|
||||
|
||||
# Ubuntu cloud images configure netplan from cloud-init only. Without it the
|
||||
# guest boots with an interface that never gets an address.
|
||||
VM_CLOUD_INIT="${VM_CLOUD_INIT:-yes}"
|
||||
vm_prompt_cloud_init "ubuntu"
|
||||
if [ "$USE_CLOUD_INIT" != "yes" ]; then
|
||||
msg_warn "Without Cloud-Init this Ubuntu image gets no network configuration - configure it in the guest yourself."
|
||||
fi
|
||||
|
||||
function default_settings() {
|
||||
select_os "${VM_OS_VERSION:-}"
|
||||
VMID=$(get_valid_nextid)
|
||||
vm_apply_machine_type "q35"
|
||||
DISK_SIZE="7G"
|
||||
@@ -102,6 +97,7 @@ function default_settings() {
|
||||
|
||||
function advanced_settings() {
|
||||
METHOD="advanced"
|
||||
select_os
|
||||
echo -e "${CLOUD}${BOLD}${DGN}Cloud-Init: ${BGN}${USE_CLOUD_INIT}${CL}"
|
||||
vm_prompt_vmid "${VMID:-$(get_valid_nextid)}"
|
||||
vm_prompt_machine_type "q35"
|
||||
@@ -115,6 +111,7 @@ function advanced_settings() {
|
||||
vm_prompt_mac "$GEN_MAC"
|
||||
vm_prompt_vlan
|
||||
vm_prompt_mtu
|
||||
vm_prompt_keyboard
|
||||
vm_prompt_verbose "no"
|
||||
vm_prompt_start_vm "yes"
|
||||
|
||||
@@ -128,11 +125,14 @@ function advanced_settings() {
|
||||
}
|
||||
|
||||
vm_start_script "Use Default Settings?\n\nDefaults:\n• 2 CPU Cores\n• 2 GB RAM\n• 7 GB Disk" 13 58
|
||||
VM_CLOUD_INIT="${VM_CLOUD_INIT:-yes}"
|
||||
vm_prompt_cloud_init "ubuntu"
|
||||
if [ "$USE_CLOUD_INIT" != "yes" ]; then
|
||||
msg_warn "Without Cloud-Init this Ubuntu image gets no network configuration or credentials; configure them in the guest yourself."
|
||||
fi
|
||||
post_to_api_vm
|
||||
|
||||
vm_select_storage "$HN"
|
||||
vm_define_disk_references 2
|
||||
DISK_IMPORT="-format ${DISK_IMPORT_FORMAT}"
|
||||
|
||||
msg_info "Retrieving the URL for the ${APP} Disk Image"
|
||||
UBUNTU_ARCH="$(vm_arch_resolve amd64 arm64)"
|
||||
@@ -147,33 +147,31 @@ FILE="$(basename "$CACHE_FILE")"
|
||||
cp -f "$CACHE_FILE" "$FILE"
|
||||
|
||||
vm_prepare_cloud_image "$FILE" "$HN" || true
|
||||
if [[ "$USE_CLOUD_INIT" != "yes" ]]; then
|
||||
vm_expand_image "$FILE" "$DISK_SIZE"
|
||||
fi
|
||||
|
||||
vm_claim_vmid
|
||||
msg_info "Creating a ${APP}"
|
||||
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
|
||||
qm create $VMID -agent 1${MACHINE} -tablet 0 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
|
||||
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||
vm_mark_created
|
||||
vm_alloc_efi_disk "$DISK0"
|
||||
qm importdisk $VMID $FILE $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||
vm_import_disk "$VMID" "$FILE" "$STORAGE" "$DISK_IMPORT_FORMAT"
|
||||
qm set $VMID \
|
||||
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \
|
||||
-scsi0 ${VM_IMPORTED_DISK},${DISK_CACHE}${THIN}size=${DISK_SIZE} \
|
||||
-boot order=scsi0 \
|
||||
-serial0 socket >/dev/null
|
||||
set_description
|
||||
|
||||
vm_resize_disk
|
||||
|
||||
if [ "$USE_CLOUD_INIT" = "yes" ] && declare -f setup_cloud_init >/dev/null 2>&1; then
|
||||
setup_cloud_init \
|
||||
"$VMID" \
|
||||
"$STORAGE" \
|
||||
"$HN" \
|
||||
"yes" \
|
||||
"${CLOUDINIT_USER:-ubuntu}" \
|
||||
"${CLOUDINIT_NETWORK_MODE:-dhcp}" \
|
||||
"${CLOUDINIT_IP:-}" \
|
||||
"${CLOUDINIT_GW:-}" \
|
||||
"${CLOUDINIT_DNS:-${CLOUDINIT_DNS_SERVERS:-1.1.1.1 8.8.8.8}}"
|
||||
|
||||
vm_provision "$VMID"
|
||||
if [[ "$USE_CLOUD_INIT" == "yes" && -n "${CLOUDINIT_SSH_KEYS:-}" ]]; then
|
||||
$STD qm set "$VMID" --sshkeys "$CLOUDINIT_SSH_KEYS"
|
||||
fi
|
||||
if [ "$USE_CLOUD_INIT" = "yes" ]; then
|
||||
if [[ "${CLOUDINIT_NETWORK_MODE:-dhcp}" == "static" ]]; then
|
||||
setup_cloud_init_network_no_rename \
|
||||
"$VMID" \
|
||||
@@ -186,16 +184,21 @@ if [ "$USE_CLOUD_INIT" = "yes" ] && declare -f setup_cloud_init >/dev/null 2>&1;
|
||||
fi
|
||||
|
||||
msg_ok "Created a ${APP} ${CL}${BL}(${HN})"
|
||||
if [ "$START_VM" = "yes" ]; then
|
||||
msg_info "Starting ${APP}"
|
||||
$STD qm start $VMID
|
||||
msg_ok "Started ${APP}"
|
||||
fi
|
||||
vm_start_vm "$APP"
|
||||
vm_wait_for_ip 120 || true
|
||||
|
||||
post_update_to_api "done" "none"
|
||||
msg_ok "Completed successfully!\n"
|
||||
if [ "$USE_CLOUD_INIT" = "yes" ] && declare -f display_cloud_init_info >/dev/null 2>&1; then
|
||||
display_cloud_init_info "$VMID" "$HN"
|
||||
else
|
||||
echo -e "Cloud-Init is disabled. The VM disk was resized on the Proxmox side only.\nIf the guest does not auto-expand its root filesystem after first boot, expand it manually inside the VM.\n\nMore info at https://github.com/community-scripts/ProxmoxVED/discussions/272 \n"
|
||||
fi
|
||||
|
||||
vm_print_summary \
|
||||
"Ubuntu Release=${var_version} (${UBUNTU_CODENAME})" \
|
||||
"Cloud-Init=${USE_CLOUD_INIT}"
|
||||
|
||||
if [ "$USE_CLOUD_INIT" != "yes" ]; then
|
||||
vm_next_steps \
|
||||
"Configure guest networking and credentials manually from the VM console." \
|
||||
"The root filesystem was expanded offline where host tools allowed it."
|
||||
fi
|
||||
|
||||
vm_finish
|
||||
|
||||
Reference in New Issue
Block a user