Add flash.sh script

This script simplifies the process of erasing the target disk and
flashing `sdcard.img` onto it.
master
Dustin 2023-03-30 09:14:15 -05:00
parent b312649a50
commit 8e3d87cf45
1 changed files with 20 additions and 0 deletions

20
flash.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
dev=$(readlink -f "$1")
wipefs -fa "${dev}"
pv images/sdcard.img \
| dd of="${dev}" bs=1M conv=sparse oflag=sync
sync; sync; sync
sleep 1
for p in /sys/class/block/${dev##*/}/*/partition; do
[ -f "${p}" ] || continue
case $(cat "${p}") in
1|2)
;;
*)
p=${p%/*}
wipefs -fa /dev/${p##*/}
;;
esac
done