--- ddimage 2016-06-04 19:16:29.472793943 -0400 +++ ddimage.mab 2016-06-04 20:52:28.756049494 -0400 @@ -2,7 +2,18 @@ # # Copy a good Raspbian image to an SD writer -target=/dev/${1-sdd} +pn=$(basename $0) + +if ! [ $# -eq 2 ] +then + echo "${pn} Requires 2 arguments" + echo "Usage: ${pn} " + echo "Example: ${pn} sdd 2016-03-18-raspbian-jessie-lite.img.zip" + exit 1 +fi + +#Should we really try and guess this? I think the user should supply it... +target=/dev/${1} echo "Checking $target" if ls $target >/dev/null 2>&1 @@ -27,20 +38,21 @@ echo "$target is not mounted" fi -set -- *.img +#Shifts out $# +#Even worse if we are in a dir full of imgs... +#set -- *.img -if [ $# != 1 ] +if [ -f $2 ] then - echo "Need a unique image file." - exit 1 -else - image=`ls *img` + echo "Unziping ${2}..." + unzip $2 + image=${2%%.*}.img fi if [ -f $image ] then echo "Copying $image..." - dcfldd bs=4M if=$image of=$target + dcfldd statusinterval=16 sizeprobe=if bs=4M if=$image of=$target else echo "No .img file, bailing out!" exit 1