Skip to content

Instantly share code, notes, and snippets.

@BrixSat
Created December 31, 2024 09:57
Show Gist options
  • Save BrixSat/6be55b2504e8d6715d89c7f3f8d020d1 to your computer and use it in GitHub Desktop.
Save BrixSat/6be55b2504e8d6715d89c7f3f8d020d1 to your computer and use it in GitHub Desktop.
Download all versions (excluding rc) available from mikrotik site.
#!/bin/bash
function downloadFile
{
url="${1}"
# If url starts with //
if [[ "${url}" = "//"* ]]
then
url="https:${url}"
fi
# Grab the extension the path and the filename
extension=$(echo "${url}" | sed 's/^.*\.//')
path_with_file=$(echo "${url}" | sed 's/https:\/\/download.mikrotik.com//g')
file=$(basename "$path_with_file")
path_without_file=$(echo "$path_with_file" | sed "s/$file//g")
if [ ! -d ".${path_without_file}" ]
then
mkdir -p ".${path_without_file}"
fi
if [ -f ".${path_with_file}" ]
then
echo "Already exists $file"
return
fi
wget "${url}"
mv "${file}" ".${path_without_file}"
}
HTML=$(curl https://mikrotik.com/download)
#HTML=$(curl http://127.0.0.1/download)
for version in $(echo -n "$HTML" | egrep "npk|bin|zip|exe|vdi|vmdk|vhdx|vhd|ova|lzb" | sed -r 's~(href="|src=")([^"]+).*~\n\1\2~g' | awk '/^(href|src)/,//' | sed 's/href="//g')
do
if [[ $version =~ [rR][cC] ]]
then
echo "Ignoring rc version $version".
continue
fi
echo "Downloading $version"
downloadFile "$version" "routeros7"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment