From 46f262ade7c3bcd8914b0d669f24ad4f4790d8ef Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 15:54:41 +0000 Subject: [PATCH 1/2] proxmox/chr_install.sh: use correct NEWEST7 endpoint for version lookup The NEWESTv7. path returns 404; the working path is NEWEST7.. Also reject placeholder values like '0.00' so an empty branch does not get offered as a default version. --- proxmox/chr_install.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/proxmox/chr_install.sh b/proxmox/chr_install.sh index e972a51..684aa43 100644 --- a/proxmox/chr_install.sh +++ b/proxmox/chr_install.sh @@ -46,12 +46,15 @@ valid_version() { } # fetch_channel CHANNEL — print the newest version for a RouterOS channel. -# CHANNEL is one of: stable, long-term, testing. Prints empty on failure. +# CHANNEL is one of: stable, long-term, testing. Prints empty on failure or +# when the channel returns a placeholder (e.g. "0.00" for an empty branch). fetch_channel() { - local channel="$1" line - # The NEWESTv7. file contains: " " - line="$(wget -qO- "${MIKROTIK_UPG}/NEWESTv7.${channel}" 2>/dev/null || true)" - echo "${line%% *}" + local channel="$1" line ver + # The NEWEST7. file contains: " " + line="$(wget -qO- "${MIKROTIK_UPG}/NEWEST7.${channel}" 2>/dev/null || true)" + ver="${line%% *}" + # Only accept a real release (major version >= 1); reject empty / "0.00". + [[ "$ver" =~ ^[1-9][0-9]*\.[0-9]+(\.[0-9]+)?$ ]] && echo "$ver" } echo "############## Start of Script ##############" From a9429020087dbb35d4c4cc94b1cd1333844fb37a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 12 Jun 2026 16:00:43 +0000 Subject: [PATCH 2/2] proxmox/chr_install.sh: verify version exists instead of unreliable latest lookup MikroTik's legacy NEWEST*/LATEST.* version feeds are frozen at 7.12.1 and no longer reflect current releases, so auto-suggesting a 'latest' version was misleading. Replace it with a prompt loop that validates the version format and confirms the CHR image actually exists on the download server (HEAD request) before proceeding, re-prompting on invalid/missing versions. Point users to https://mikrotik.com/download for current Long-term/Stable. --- proxmox/chr_install.sh | 53 ++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/proxmox/chr_install.sh b/proxmox/chr_install.sh index 684aa43..f364f6f 100644 --- a/proxmox/chr_install.sh +++ b/proxmox/chr_install.sh @@ -12,7 +12,6 @@ set -euo pipefail TEMP_DIR="/root/temp" NODE="$(hostname)" MIKROTIK_DL="https://download.mikrotik.com/routeros" -MIKROTIK_UPG="https://upgrade.mikrotik.com/routeros" # Defaults for the created VM (override here if needed) VM_MEMORY=256 @@ -45,16 +44,10 @@ valid_version() { [[ "$1" =~ ^[0-9]+\.[0-9]+(\.[0-9]+)?$ ]] } -# fetch_channel CHANNEL — print the newest version for a RouterOS channel. -# CHANNEL is one of: stable, long-term, testing. Prints empty on failure or -# when the channel returns a placeholder (e.g. "0.00" for an empty branch). -fetch_channel() { - local channel="$1" line ver - # The NEWEST7. file contains: " " - line="$(wget -qO- "${MIKROTIK_UPG}/NEWEST7.${channel}" 2>/dev/null || true)" - ver="${line%% *}" - # Only accept a real release (major version >= 1); reject empty / "0.00". - [[ "$ver" =~ ^[1-9][0-9]*\.[0-9]+(\.[0-9]+)?$ ]] && echo "$ver" +# version_exists VERSION — return 0 if a CHR image for VERSION is published on +# MikroTik's download server. Uses a HEAD request so nothing is downloaded. +version_exists() { + wget -q --spider "${MIKROTIK_DL}/$1/chr-$1.img.zip" } echo "############## Start of Script ##############" @@ -69,24 +62,28 @@ else fi #### 2. determine version to deploy +# MikroTik no longer publishes a reliable "latest version" file (the legacy +# NEWEST*/LATEST.* feeds are frozen at 7.12.1), so instead of guessing the +# newest release we let the user pick one and verify it actually exists. echo "## Preparing for image download and VM creation!" -echo "-- Looking up current RouterOS releases from MikroTik..." -stable_ver="$(fetch_channel stable)" -lt_ver="$(fetch_channel long-term)" - -[ -n "$lt_ver" ] && echo " Long-term (recommended): $lt_ver" -[ -n "$stable_ver" ] && echo " Stable: $stable_ver" -[ -z "$lt_ver$stable_ver" ] && \ - echo " (could not reach MikroTik — enter a version manually)" - -# Default to long-term, fall back to stable. -default_ver="${lt_ver:-$stable_ver}" -prompt="Please input CHR version to deploy (6.38.2, 6.40.1, etc)" -[ -n "$default_ver" ] && prompt="$prompt [$default_ver]" -read -r -p "$prompt: " version -version="${version:-$default_ver}" - -valid_version "$version" || die "Invalid version format: '$version'" +echo "-- Current Long-term / Stable releases are listed at https://mikrotik.com/download" + +while true; do + read -r -p "Please input CHR version to deploy (e.g. 7.18.2): " version + if ! valid_version "$version"; then + echo "-- Invalid version format, please try again (e.g. 7.18.2)." + continue + fi + # An already-downloaded image is good enough; otherwise confirm it exists. + if [ -f "$TEMP_DIR/chr-$version.img" ]; then + break + fi + echo "-- Verifying that CHR $version exists on MikroTik..." + if version_exists "$version"; then + break + fi + echo "-- CHR $version was not found on the download server, try another version." +done #### 3. download image if needed img="$TEMP_DIR/chr-$version.img"