diff --git a/misc/build.func b/misc/build.func index 977bc2a0..40e1d929 100644 --- a/misc/build.func +++ b/misc/build.func @@ -3007,12 +3007,15 @@ create_lxc_container() { pveam update >/dev/null 2>&1 || msg_warn "Could not update template catalog (pveam update failed)." mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2>/dev/null | - grep -E "^${TEMPLATE_SEARCH}-.*${TEMPLATE_PATTERN}" | + grep -E "^${TEMPLATE_SEARCH}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) ONLINE_TEMPLATE="" [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE="${ONLINE_TEMPLATES[-1]}" + msg_debug "Found ${#LOCAL_TEMPLATES[@]} local templates, ${#ONLINE_TEMPLATES[@]} online templates" + msg_debug "ONLINE_TEMPLATE='$ONLINE_TEMPLATE'" + if [[ ${#LOCAL_TEMPLATES[@]} -gt 0 ]]; then TEMPLATE="${LOCAL_TEMPLATES[-1]}" TEMPLATE_SOURCE="local" @@ -3021,6 +3024,8 @@ create_lxc_container() { TEMPLATE_SOURCE="online" fi + echo -e "Selected TEMPLATE='$TEMPLATE' SOURCE='$TEMPLATE_SOURCE'" + TEMPLATE_PATH="$(pvesm path $TEMPLATE_STORAGE:vztmpl/$TEMPLATE 2>/dev/null || true)" if [[ -z "$TEMPLATE_PATH" ]]; then TEMPLATE_BASE=$(awk -v s="$TEMPLATE_STORAGE" '$1==s {f=1} f && /path/ {print $2; exit}' /etc/pve/storage.cfg) @@ -3068,7 +3073,7 @@ create_lxc_container() { ) mapfile -t ONLINE_TEMPLATES < <( pveam available -section system 2>/dev/null | - grep -E "^${TEMPLATE_SEARCH}-.*${TEMPLATE_PATTERN}" | + grep -E "^${TEMPLATE_SEARCH}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V ) ONLINE_TEMPLATE=""