VARA Downloader - Added support for a VARA helper script to dynamically find and download VARA applications. (Why do Windows users like spaces in filenames?

This commit is contained in:
Gaston Gonzalez
2025-02-28 04:35:43 -07:00
parent a127fe7c10
commit 9f21077793
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash
# Author : Gaston Gonzalez
# Date : 28 February 2025
# Purpose : Download utility for VARA applications
BASE_HTML_FILE="vara-index.html"
cleanup() {
[[ -f "$BASE_HTML_FILE" ]] && rm "${BASE_HTML_FILE}"
}
trap cleanup EXIT
function usage() {
echo "Usage: $(basename $0) <pattern>"
echo " pattern - VARA filename substring pattern to match on"
}
if [ $# -ne 1 ]; then
usage
exit 1
fi
FILENAME_PATTERN="$1"
BASE_URL="https://downloads.winlink.org"
INDEX_URL="${BASE_URL}/VARA%20Products/"
# 1. Fetch main VARA download page as HTML
curl -s -f -L -o ${BASE_HTML_FILE} ${INDEX_URL}
[[ $? -ne 0 ]] && et-log "Error fetching VARA index page: ${BASE_URL}" && exit 1
# 2. Extract all links from index page
VARA_FILE_PATH=$(cat ${BASE_HTML_FILE} | pup 'a attr{href}' | grep "${FILENAME_PATTERN}")
[[ $? -ne 0 ]] && et-log "Error finding VARA file matching specified pattern" && exit 1
#3. Check for multiple matches
if [[ "${VARA_FILE_PATH}" =~ [[:space:]] ]]; then
echo -e "\n${VARA_FILE_PATH}\n"
et-log "Multiple files matched. Try again with a more specific pattern."
exit 1
fi
FULL_URL="${BASE_URL}${VARA_FILE_PATH}"
et-log "Found ${VARA_FILE_PATH}"
et-log "Downloading: ${FULL_URL}"
curl -s -f -L -O "${FULL_URL}"
exit $?