Created
August 19, 2021 19:33
-
-
Save kevdougful/e04ba6981a4c4403acc6fc1318b3f37c to your computer and use it in GitHub Desktop.
Get Latest Raspberry Pi OS image
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 | |
# Downloads, checks and unzips the latest image file for RaspiOS Lite | |
# Get the download URL for the latest version | |
dlurl=https://downloads.raspberrypi.org/raspios_lite_armhf_latest | |
url=$(curl -ILs -w %{url_effective} $dlurl | tail -1) | |
expect=$(curl -s "$url.sha256" | cut -d" " -f1) # checksum | |
curl -sL -o raspios.zip $url | |
# Check the downloaded file | |
actual=$(sha256sum raspios.zip | cut -d" " -f1) | |
if [ "$actual" != "$expect" ] | |
then | |
echo "downloaded file failed checksum test" | |
echo "download sum: $actual" | |
echo "expected sum: $expect" | |
exit 1 | |
fi | |
# Inflate the zip file | |
unzip -oq raspios.zip | |
imgfile=$(ls *.img | tail -1) | |
rm raspios.zip | |
echo $imgfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment