Last active
January 9, 2020 12:07
-
-
Save simonjenny/d4c03c196935844e5b41607b771a76d2 to your computer and use it in GitHub Desktop.
Create-A-Pi
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
#!/bin/bash | |
command -v pv >/dev/null 2>&1 || { echo "Dieses Script benötigt das Programm pv." >&2; exit 1; } | |
# Shell Script for creating a pi sd card iwth the latest Rasbian | |
# Author <simon.jenny@me.com> Simon Jenny | |
# | |
# ------------------------------------------- | |
if [ "$1" == "" ]; then | |
echo "Drive Folder Parameter missing!" | |
echo "Usage : create-a-pi DRIVE (eg /dev/disk2)" | |
echo "Here are all your mounted drives:" | |
diskutil list | |
exit 0 | |
fi | |
sudo diskutil umountDisk $1 &>/dev/null | |
echo "Creating a Raspberry Pi SD Card with the latest Raspbian lite" | |
echo "Go grab a coffee. This may take a while..." | |
echo "Grabbing latest Build..." | |
wget https://downloads.raspberrypi.org/raspbian_lite_latest -q --show-progress -O raspbian-lite-latest.zip | |
unzip -qo raspbian-lite-latest.zip && rm raspbian-lite-latest.zip | |
IMAGE=$(ls -a *.img | tr ' ' '\n' |tail -1) | |
FILESIZE=$(stat -f%z "$IMAGE") | |
echo "Cloning image $IMAGE to $1" | |
sudo dd if="$IMAGE" bs=4m | pv --size $FILESIZE | sudo dd of=$1 bs=4m | |
sudo diskutil umountDisk $1 | |
osascript -e 'display notification "Your Pi SD Card is ready!" with title "Create-A-Pi"' | |
echo "All Done, yay!" | |
rm -Rf $IMAGE | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment