Files
start-os/build/raspberry-pi/rip-image.sh
Aiden McClelland 6680b32579 fix regex in image rip script (#2002)
* fix regex in image rip script

* gitignore debian dir

* instructions

* put titles in code spans
2022-11-30 16:12:07 -07:00

31 lines
917 B
Bash
Executable File

#!/bin/bash
set -e
TMPDIR=$(mktemp -d)
ROOT_PARTITION=$(readlink -f /dev/disk/by-label/rootfs)
BOOT_PARTITION=$(readlink -f /dev/disk/by-label/boot)
if [[ "$ROOT_PARTITION" =~ ^/dev/loop ]] || [[ "$BOOT_PARTITION" =~ ^/dev/loop ]]; then
>&2 echo 'You are currently ripping from a loop device.'
>&2 echo 'This is probably a mistake, and usually means you failed to detach a .img file.'
read -p "Continue anyway? [y/N]" -n 1 -r
echo
if ! [[ "$REPLY" =~ ^[Yy]$ ]]; then
exit 1
fi
fi
sudo mount $ROOT_PARTITION $TMPDIR/
sudo mount $BOOT_PARTITION $TMPDIR/current/boot/
sudo sed -i 's/PARTUUID=[a-f0-9]\+/PARTUUID=cb15ae4d/g' $TMPDIR/current/etc/fstab
sudo sed -i 's/PARTUUID=[a-f0-9]\+/PARTUUID=cb15ae4d/g' $TMPDIR/current/boot/cmdline.txt
rm -f eos.raspberrypi.squashfs
sudo mksquashfs $TMPDIR/current/ eos.raspberrypi.squashfs
sudo umount $TMPDIR/current/boot/
sudo umount $TMPDIR/
rm -rf $TMPDIR