From 09004d4c098109391dedeb98a7fcaaa63830f342 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Thu, 29 Jan 2026 19:54:54 +0100 Subject: [PATCH] Update share-common.func --- scripts/global/share-common.func | 110 ++++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 8 deletions(-) diff --git a/scripts/global/share-common.func b/scripts/global/share-common.func index 7ca731ac..8b968f65 100644 --- a/scripts/global/share-common.func +++ b/scripts/global/share-common.func @@ -6,6 +6,89 @@ + + +# ========================================================== +# Ensure repositories are properly configured +# ========================================================== +ensure_repositories() { + local pve_version need_update=false + pve_version=$(pveversion 2>/dev/null | grep -oP 'pve-manager/\K[0-9]+' | head -1) + + if [[ -z "$pve_version" ]]; then + msg_error "$(translate 'Unable to detect Proxmox version.')" + return 1 + fi + + if (( pve_version >= 9 )); then + # ===== PVE 9 (Debian 13 - trixie) ===== + # proxmox.sources (no-subscription) - create if missing + if [[ ! -f /etc/apt/sources.list.d/proxmox.sources ]]; then + cat > /etc/apt/sources.list.d/proxmox.sources <<'EOF' +Enabled: true +Types: deb +URIs: http://download.proxmox.com/debian/pve +Suites: trixie +Components: pve-no-subscription +Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg +EOF + need_update=true + fi + + # debian.sources - create if missing + if [[ ! -f /etc/apt/sources.list.d/debian.sources ]]; then + cat > /etc/apt/sources.list.d/debian.sources <<'EOF' +Types: deb +URIs: http://deb.debian.org/debian/ +Suites: trixie trixie-updates +Components: main contrib non-free-firmware +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg + +Types: deb +URIs: http://security.debian.org/debian-security/ +Suites: trixie-security +Components: main contrib non-free-firmware +Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg +EOF + need_update=true + fi + + else + # ===== PVE 8 (Debian 12 - bookworm) ===== + local sources_file="/etc/apt/sources.list" + + # Debian base (create or append minimal lines if missing) + if ! grep -qE 'deb .* bookworm .* main' "$sources_file" 2>/dev/null; then + { + echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware" + echo "deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware" + echo "deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware" + } >> "$sources_file" + need_update=true + fi + + # Proxmox no-subscription list (classic) if missing + if [[ ! -f /etc/apt/sources.list.d/pve-no-subscription.list ]]; then + echo "deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription" \ + > /etc/apt/sources.list.d/pve-no-subscription.list + need_update=true + fi + fi + + # apt-get update only if needed or lists are empty + if [[ "$need_update" == true ]] || [[ ! -d /var/lib/apt/lists || -z "$(ls -A /var/lib/apt/lists 2>/dev/null)" ]]; then + msg_info "$(translate 'Updating APT package lists...')" + apt-get update >/dev/null 2>&1 || apt-get update + msg_ok "$(translate 'APT package lists updated')" + fi + + return 0 +} + + +# ========================================================== + + if [[ -n "${__PROXMENUX_SHARE_COMMON__}" ]]; then return 0 fi @@ -41,7 +124,7 @@ pmx_share_map_set() { - +# ========================================================== @@ -120,7 +203,7 @@ pmx_choose_or_create_group() { - +# ========================================================== @@ -179,7 +262,7 @@ pmx_ensure_host_group() { - +# ========================================================== @@ -214,7 +297,7 @@ pmx_prepare_host_shared_dir() { - +# ========================================================== @@ -257,7 +340,7 @@ pmx_select_host_mount_point() { - +# ========================================================== @@ -311,7 +394,7 @@ select_host_directory_() { - +# ========================================================== @@ -366,7 +449,7 @@ select_host_directory__() { - +# ========================================================== @@ -421,6 +504,9 @@ select_host_directory() { +# ========================================================== + + select_lxc_container() { @@ -455,6 +541,14 @@ select_lxc_container() { + +# ========================================================== + + + + + + select_container_mount_point_() { local ctid="$1" local host_dir="$2" @@ -500,7 +594,7 @@ select_container_mount_point_() { - +# ==========================================================