Work-in-progress. This repository contains some scripts to prepare SD card images for the raspberry Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

24 lines
961 B

#!/bin/bash
set -euo pipefail
IMAGE_DATE=2018-11-15
# Weird but the image is from a different date.
FILE_DATE=2018-11-13
FILENAME="${FILE_DATE}-raspbian-stretch-lite"
for ext in info zip zip.sig; do
[[ ! -f "${FILENAME}.${ext}" ]] && curl --remote-name --location --fail "https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-${IMAGE_DATE}/${FILENAME}.${ext}"
done
# gpg --recv-keys 8738CD6B956F460C
[[ ! -f "${FILENAME}.img" ]]\
&& gpg --quiet --verify "${FILENAME}.zip.sig" "${FILENAME}.zip"\
&& unzip "${FILENAME}.zip"
BOOT_START_SECTOR=$(sfdisk --json ${FILENAME}.img | jq '.partitiontable.partitions[] | select(.type == "c") | .start')
ROOT_START_SECTOR=$(sfdisk --json ${FILENAME}.img | jq '.partitiontable.partitions[] | select(.type == "83") | .start')
sfdisk --delete "${FILENAME}.img" 2
head --bytes=2G /dev/zero | pv --size=2G >> "${FILENAME}.img"
echo "start=$ROOT_START_SECTOR type=83" | sfdisk "${FILENAME}.img" 2