Last active
September 22, 2016 15:31
-
-
Save cyphunk/905a299e65ccf73f631d3f19efbc1dbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Install/dd a raspberry pi os image to SD card | |
if [ $# -lt 2 ]; then | |
echo "rdisks:" | |
diskutil list | |
echo | |
echo "images:" | |
ls -t *.zip *.xz | |
echo | |
echo "usage: $0 <image.zip|xz> <rdiskpath>" | |
exit | |
fi | |
zip="$1" | |
rdisk="$2" | |
sudo -v | |
set -x | |
test -s "$zip" || exit | |
#test -b "$rdisk" || exit | |
test -e "$rdisk" || exit | |
diskutil unmountDisk "$rdisk" || exit | |
unzip $1 || xz -k -d $1 || exit | |
image="$(ls -t *.img | head -1)" | |
test -s "$image" || exit | |
set +x | |
read -p "dd over $image? (ctrl+c for no)" | |
if [ "$(uname)" == "Darwin" ]; then | |
BS="4m" | |
else | |
BS="4M" | |
fi | |
set -x | |
sudo dd if="$image" of="$2" bs=$BS || exit | |
rm -rf "$image" | |
set +x | |
echo done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment