#!/bin/sh # downloads an url [+installs to path] [+checks bit-by-bit reproducability] set -x test -z "$1" && { echo "wget.install [sha256checksum] "; exit 0; } set -e 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