From 6c7d7427bf853ff603ad2ba43748f39ee7a52c6b Mon Sep 17 00:00:00 2001 From: dreimolo Date: Sat, 16 Dec 2023 14:14:58 +0100 Subject: [PATCH] Adds check for wget and curl, and valid sample archives --- run/download-samples.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/run/download-samples.sh b/run/download-samples.sh index 66aa6125..09ddcf6b 100755 --- a/run/download-samples.sh +++ b/run/download-samples.sh @@ -2,16 +2,37 @@ set -e +# Check if wget exists +if command -v wget &> /dev/null; then + dl_prg="wget -O" +elif command -v curl &> /dev/null; then + dl_prg="curl -o" +else + echo "Neither wget nor curl found, exiting .." + exit 1 +fi + +case "$1" in +"s"|"m"|"l"|"xl") + ;; +*) + echo "Invalid argument. Must be one of 's', 'm', or 'l'." + exit 1 + ;; +esac + SAMPLE_NAME=crawl-${1:-m} SAMPLE_DIR="node-1/samples/${SAMPLE_NAME}/" function download_model { + + model=$1 url=$2 if [ ! -f $model ]; then echo "** Downloading $url" - wget -O $model $url + $dl_prg $model $url fi } @@ -23,7 +44,7 @@ fi mkdir -p node-1/samples/ SAMPLE_TARBALL=samples/${SAMPLE_NAME}.tar.gz -download_model ${SAMPLE_TARBALL} https://downloads.marginalia.nu/${SAMPLE_TARBALL} || rm ${SAMPLE_TARBALL} +download_model ${SAMPLE_TARBALL} https://downloads.marginalia.nu/${SAMPLE_TARBALL} if [ ! -f ${SAMPLE_TARBALL} ]; then echo "!! Failed"