diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index 30121f7c..5874ac69 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -106,42 +106,23 @@ function select_storage() { exit 221 } - # Gather valid storages from /etc/pve/storage.cfg - local -a VALID_STORAGES=() - local CURRENT_STORAGE="" - while read -r LINE; do - if [[ "$LINE" =~ ^(dir|lvm|lvmthin|zfspool|.*):[[:space:]]*(.+)$ ]]; then - CURRENT_STORAGE="${BASH_REMATCH[2]}" - elif [[ "$LINE" =~ ^[[:space:]]*content[[:space:]]*=[[:space:]]*(.+)$ ]]; then - local CONTENTS="${BASH_REMATCH[1]}" - [[ ",${CONTENTS}," =~ ,$CONTENT, ]] && VALID_STORAGES+=("$CURRENT_STORAGE") - fi - done COL_WIDTH)) && COL_WIDTH=${#DISPLAY} done < <(pvesm status -content "$CONTENT" | awk 'NR>1') if [ ${#MENU[@]} -eq 0 ]; then - msg_error "No storage found that supports '${CONTENT}'." + msg_error "No storage found for content type '$CONTENT'." exit 203 fi @@ -259,18 +240,12 @@ if ! pveam list "$TEMPLATE_STORAGE" | grep -q "$TEMPLATE" || ! zstdcat "$TEMPLAT for attempt in {1..3}; do msg_info "Attempt $attempt: Downloading LXC template..." - if command -v timeout >/dev/null; then - timeout --foreground 120 pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null 2>&1 - else - pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null 2>&1 - fi - - if [[ $? -eq 0 ]]; then + if timeout 120 pveam download "$TEMPLATE_STORAGE" "$TEMPLATE" >/dev/null 2>&1; then msg_ok "Template download successful." break fi - if [[ $attempt -eq 3 ]]; then + if [ $attempt -eq 3 ]; then msg_error "Failed after 3 attempts. Please check your Proxmox host’s internet access or manually run:\n pveam download $TEMPLATE_STORAGE $TEMPLATE" exit 208 fi