vps/util/wget

19 lines
607 B
Text
Raw Normal View History

#!/bin/sh
# downloads an url [+installs to path] [+checks bit-by-bit reproducability]
2026-03-05 22:02:04 +01:00
set -x
test -z "$1" && { echo "wget.install [sha256checksum] <url>"; exit 0; }
set -e
2026-03-05 22:02:04 +01:00
test -n "$2" && url="$2" || url="$1"
file=$(basename "$url")
test -n "$OUT" || OUT="pkg"
wget -O "$file" "$url"
sha256sum "$file"
if test -n "$2"; then
echo "$1 $file" | sha256sum --check || { echo "[!] wrong checksum.."; rm $file; exit 1; }
fi
# extract
test -d $OUT || mkdir -p $OUT
mv $file $OUT/. && cd $OUT
echo $file | grep -q '\.zip' && unzip $file && rm $file
echo $file | grep -q '\.tar' && tar -xvf $file && rm $file