xgo/docker/base/fetch.sh

24 lines
520 B
Bash

#!/bin/bash
#
# Contains a simple fetcher to download a file from a remote URL and verify its
# SHA1 checksum.
#
# Usage: fetch.sh <remote URL> <SHA1 checksum>
set -e
# Skip the download if no operands specified
if [ "$1" == "" -o "$2" == "" ]; then
echo "Fetch operands missing, skipping..."
exit
fi
# Pull the file from the remote URL
file=`basename $1`
echo "Downloading $1..."
wget -q $1
# Generate a desired checksum report and check against it
echo "$2 $file" > $file.sum
sha1sum -c $file.sum
rm $file.sum