#!/usr/bin/env bash

set -E -o errexit -o nounset -o pipefail

if [ $# -lt 2 ]; then
  echo "Not enough arguments!"
  echo "Use: $0 <source> <destination> [args]"
  echo "For example: $0 ubuntu.img /dev/sdc"
  exit 10
fi

SRC="$1"
shift
DST="$1"
shift

echo "dd if=$SRC of=$DST bs=32MiB status=progress conv=fsync $*"
sudo dd if="$SRC" of="$DST" bs=32MiB status=progress conv=fsync "$@"
