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