Created
December 31, 2024 09:57
Revisions
-
BrixSat created this gist
Dec 31, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!/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