second attempt to preselect last item

This commit is contained in:
juronja 2026-02-13 14:16:51 +00:00
parent a004ae98dd
commit 4a0824777a

View File

@ -299,15 +299,26 @@ function advanced_settings() {
done done
ISOARRAY=() ISOARRAY=()
while read -r ISOPATH; do # Fetch and sort the ISO paths into a bash array
FILENAME=$(basename "$ISOPATH") mapfile -t ALL_ISOS < <(truenas_iso_lookup | sort -V)
ISOARRAY+=("$ISOPATH" "$FILENAME" "OFF") ISO_COUNT=${#ALL_ISOS[@]}
done < <(truenas_iso_lookup | sort -V)
if [ ${#ISOARRAY[@]} -eq 0 ]; then if [ $ISO_COUNT -eq 0 ]; then
echo "No ISOs found." echo "No ISOs found."
exit 1 exit 1
fi fi
for i in "${!ALL_ISOS[@]}"; do
ISOPATH="${ALL_ISOS[$i]}"
FILENAME=$(basename "$ISOPATH")
# Pre-select only the last item in the list
if [ "$i" -eq "$((ISO_COUNT - 1))" ]; then
ISOARRAY+=("$ISOPATH" "$FILENAME" "ON")
else
ISOARRAY+=("$ISOPATH" "$FILENAME" "OFF")
fi
done
if SELECTED_ISO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SELECT ISO TO INSTALL" --notags --radiolist "\nSelect version (BETA/RC/Latest stable):" 20 58 12 "${ISOARRAY[@]}" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if SELECTED_ISO=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SELECT ISO TO INSTALL" --notags --radiolist "\nSelect version (BETA/RC/Latest stable):" 20 58 12 "${ISOARRAY[@]}" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
echo -e "${ISO}${BOLD}${DGN}ISO Chosen: ${BGN}$(basename "$SELECTED_ISO")${CL}" echo -e "${ISO}${BOLD}${DGN}ISO Chosen: ${BGN}$(basename "$SELECTED_ISO")${CL}"
else else