#!/bin/bash
DST=""

while getopts ":d:" opt; do
  case ${opt} in
    d )
      DST=$OPTARG
      ;;
    \? )
      echo "Invalid option: $OPTARG" 1>&2
      ;;
    : )
      echo "Invalid option: $OPTARG requires an argument" 1>&2
      ;;
  esac
done

echo ${DST}
if [ -b "${DST}" ]; then
  echo "Found block device: ${DST}"
  read -p "Press any key to continue... "
else
  print "${DST} does not exist or is not a block device."
  exit 1
fi

curl -n ~/.netrc \
--silent http://nfs-netboot.engr.unr.edu/images/win10_1909.img.zst | \
zstd --long=31 -T4 -d --stdout -q | \
pv -e -r -p -s 128G > ${DST}

sync
