Skip to content

Instantly share code, notes, and snippets.

@kevdougful
Created August 19, 2021 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevdougful/e04ba6981a4c4403acc6fc1318b3f37c to your computer and use it in GitHub Desktop.
Save kevdougful/e04ba6981a4c4403acc6fc1318b3f37c to your computer and use it in GitHub Desktop.
Get Latest Raspberry Pi OS image
#!/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