From 3e31d59d82006a89bf172e2d47ec7f332c60769b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:54:36 +0200 Subject: [PATCH] Update build.func --- misc/build.func | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/misc/build.func b/misc/build.func index 55fc96a8..330c0b90 100644 --- a/misc/build.func +++ b/misc/build.func @@ -3004,10 +3004,10 @@ create_lxc_container() { # Step 1: Search in local storage LOCAL_TEMPLATE=$(pveam list "$TEMPLATE_STORAGE" 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1) - + # Step 2: Check pveam for available version (could be newer) ONLINE_TEMPLATE=$(pveam available -section system 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1) - + # Decide what to use if [[ -n "$LOCAL_TEMPLATE" && -n "$ONLINE_TEMPLATE" ]]; then # Both exist - check if online is newer @@ -3017,16 +3017,16 @@ create_lxc_container() { echo "" read -p "Download newer version? [y/N]: " answer case "${answer,,}" in - y|yes) - TEMPLATE="$ONLINE_TEMPLATE" - TEMPLATE_SOURCE="online" - msg_ok "Using newer version: $TEMPLATE" - ;; - *) - TEMPLATE="$LOCAL_TEMPLATE" - TEMPLATE_SOURCE="local" - msg_ok "Using local version: $TEMPLATE" - ;; + y | yes) + TEMPLATE="$ONLINE_TEMPLATE" + TEMPLATE_SOURCE="online" + msg_ok "Using newer version: $TEMPLATE" + ;; + *) + TEMPLATE="$LOCAL_TEMPLATE" + TEMPLATE_SOURCE="local" + msg_ok "Using local version: $TEMPLATE" + ;; esac else # Same version @@ -3052,7 +3052,7 @@ create_lxc_container() { echo " • The version is not yet available in the Proxmox template repository" echo " • Your Proxmox VE might need an update to access newer templates" echo " • The version number might be incorrect" - + mapfile -t AVAILABLE_VERSIONS < <( pveam available -section system 2>/dev/null | awk '{print $NF}' | @@ -3060,7 +3060,7 @@ create_lxc_container() { sed -E "s/.*${PCT_OSTYPE}-([0-9]+(\.[0-9]+)?).*/\1/" | sort -u -V ) - + if [[ ${#AVAILABLE_VERSIONS[@]} -gt 0 ]]; then echo "" msg_info "Available ${PCT_OSTYPE} versions:" @@ -3069,7 +3069,7 @@ create_lxc_container() { done echo "" read -p "Select version [1-${#AVAILABLE_VERSIONS[@]}] or press Enter to cancel: " choice - + if [[ "$choice" =~ ^[0-9]+$ ]] && [[ "$choice" -ge 1 ]] && [[ "$choice" -le ${#AVAILABLE_VERSIONS[@]} ]]; then PCT_OSVERSION="${AVAILABLE_VERSIONS[$((choice - 1))]}" TEMPLATE=$(pveam available -section system 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1) @@ -3180,7 +3180,7 @@ create_lxc_container() { } else msg_info "Installation cancelled" - exit 0 + exit 1 fi else msg_error "No ${PCT_OSTYPE} templates available"