blob: eba47bc09be7ab66637729557130e5214db11ab7 [file] [log] [blame]
Austin Schuh5e25dce2020-10-24 13:29:30 -07001#!/bin/bash
2
3set -e
4
5IMAGE="2020-08-20-raspios-buster-armhf-lite.img"
6DEVICE="/dev/sda"
7
8if mount | grep "${DEVICE}" >/dev/null ;
9then
10 echo "Overwriting a mounted partition, is ${DEVICE} the sd card?"
11 exit 1
12fi
13
14sudo dd if=${IMAGE} of=${DEVICE} bs=1M status=progress
15
16PARTITION="${IMAGE}.partition"
17
18mkdir -p "${PARTITION}"
19sudo mount "${DEVICE}2" "${PARTITION}"
20
21function target() {
22 HOME=/root/ USER=root sudo proot -0 -q qemu-arm-static -w / -r "${PARTITION}" "$@"
23}
24
25target /root/bin/change_hostname.sh "${1}"
26
27echo "Starting a shell for any manual configuration"
28target /bin/bash --rcfile /root/.bashrc
29
30sudo umount "${PARTITION}"