burrow-pi-img/export-noobs/00-release/files/partition_setup.sh

47 lines
1.0 KiB
Bash
Raw Permalink Normal View History

2016-05-27 10:56:23 +00:00
#!/bin/sh
2018-12-11 15:12:40 +00:00
#supports_backup in PINN
2016-05-27 10:56:23 +00:00
set -ex
# shellcheck disable=SC2154
2016-05-27 10:56:23 +00:00
if [ -z "$part1" ] || [ -z "$part2" ]; then
printf "Error: missing environment variable part1 or part2\n" 1>&2
exit 1
fi
mkdir -p /tmp/1 /tmp/2
mount "$part1" /tmp/1
mount "$part2" /tmp/2
2017-03-07 15:13:22 +00:00
sed /tmp/1/cmdline.txt -i -e "s|root=[^ ]*|root=${part2}|"
2018-12-11 15:12:40 +00:00
sed /tmp/2/etc/fstab -i -e "s|^[^#].* / |${part2} / |"
sed /tmp/2/etc/fstab -i -e "s|^[^#].* /boot |${part1} /boot |"
2016-05-27 10:56:23 +00:00
# shellcheck disable=SC2154
if [ -z "$restore" ]; then
2018-12-11 15:12:40 +00:00
if [ -f /mnt/ssh ]; then
cp /mnt/ssh /tmp/1/
fi
2017-03-03 13:22:06 +00:00
2018-12-11 15:12:40 +00:00
if [ -f /mnt/ssh.txt ]; then
cp /mnt/ssh.txt /tmp/1/
fi
2017-03-03 13:22:06 +00:00
2018-12-11 15:12:40 +00:00
if [ -f /settings/wpa_supplicant.conf ]; then
cp /settings/wpa_supplicant.conf /tmp/1/
fi
2017-03-06 11:49:13 +00:00
2018-12-11 15:12:40 +00:00
if ! grep -q resize /proc/cmdline; then
if ! grep -q splash /tmp/1/cmdline.txt; then
sed -i "s| quiet||g" /tmp/1/cmdline.txt
fi
sed -i 's| init=/usr/lib/raspi-config/init_resize.sh||' /tmp/1/cmdline.txt
else
sed -i '1 s|.*|& sdhci.debug_quirks2=4|' /tmp/1/cmdline.txt
2018-12-11 15:12:40 +00:00
fi
2016-05-27 10:56:23 +00:00
fi
umount /tmp/1
umount /tmp/2