From 9f21077793a4991fa95dd447c38225d9482429ba Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 28 Feb 2025 04:35:43 -0700 Subject: [PATCH] VARA Downloader - Added support for a VARA helper script to dynamically find and download VARA applications. (Why do Windows users like spaces in filenames? --- .../etc/skel/add-ons/wine/vara-downloader.sh | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 overlay/etc/skel/add-ons/wine/vara-downloader.sh diff --git a/overlay/etc/skel/add-ons/wine/vara-downloader.sh b/overlay/etc/skel/add-ons/wine/vara-downloader.sh new file mode 100755 index 0000000..9da1221 --- /dev/null +++ b/overlay/etc/skel/add-ons/wine/vara-downloader.sh @@ -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) " + 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 $?