Fix pi root deployment scripts
bs=1M speeds up deployment by 4x.
Also, default to 971 and make modify_rootfs.sh more robust to changes in
the image to modify
Change-Id: I2e1656a03ad2ec1c23b6d4d86759dcf0167659f6
diff --git a/y2020/vision/rootfs/README b/y2020/vision/rootfs/README
deleted file mode 100644
index 2320774..0000000
--- a/y2020/vision/rootfs/README
+++ /dev/null
@@ -1,16 +0,0 @@
-This modifies a stock debian root filesystem to be able to operate as a vision
-pi. It is not trying to be reproducible, but should be good enough for FRC
-purposes.
-
-The default hostname and IP is pi-8971-1, 10.89.71.101.
- Username pi, password raspberry.
-
-Download 2020-02-13-raspbian-buster-lite.img (or equivalent) and edit
-modify_rootfs.sh to point to it. Run modify_rootfs.sh to build the filesystem
-(you might need to hit return in a spot or two).
-
-After confirming the target device, deploy with
- dd if=2020-02-13-raspbian-buster-lite.img of=/dev/sdX
-
-From there, log in, sudo to root, and run /root/bin/change_hostname.sh to
-change the hostname to the actual target.
diff --git a/y2020/vision/rootfs/README.md b/y2020/vision/rootfs/README.md
new file mode 100644
index 0000000..ee34edf
--- /dev/null
+++ b/y2020/vision/rootfs/README.md
@@ -0,0 +1,21 @@
+This modifies a stock debian root filesystem to be able to operate as a vision
+pi. It is not trying to be reproducible, but should be good enough for FRC
+purposes.
+
+The default hostname and IP is pi-8971-1, 10.89.71.101.
+ Username pi, password raspberry.
+
+Download 2020-02-13-raspbian-buster-lite.img (or any newer buster version)
+from `https://www.raspberrypi.org/downloads/raspberry-pi-os/` and
+edit `modify_rootfs.sh` to point to it. Run modify_rootfs.sh to build the
+filesystem (you might need to hit return in a spot or two).
+
+After confirming the target device, deploy by copying the contents of the image
+to the SD card.
+ `dd if=2020-02-13-raspbian-buster-lite.img of=/dev/sdX bs=1M`
+
+Use `lsblk` to find the device and make absolutely sure this isn't your hard
+drive or something else.
+
+From there, log in, `sudo` to `root`, and run `/root/bin/change_hostname.sh` to
+change the hostname to the actual target.
diff --git a/y2020/vision/rootfs/change_hostname.sh b/y2020/vision/rootfs/change_hostname.sh
index 712aba9..f36c439 100755
--- a/y2020/vision/rootfs/change_hostname.sh
+++ b/y2020/vision/rootfs/change_hostname.sh
@@ -38,3 +38,9 @@
echo -e "${IP_BASE}.2\troborio" >> /etc/hosts
fi
+if grep '^10\.[0-9]*\.[0-9]*\.13\s*laptop$' /etc/hosts >/dev/null;
+then
+ sed -i "s/^10\.[0-9]*\.[0-9]*\(\.13\s*laptop\)$/${IP_BASE}\1/" /etc/hosts
+else
+ echo -e "${IP_BASE}.13\tlaptop" >> /etc/hosts
+fi
diff --git a/y2020/vision/rootfs/modify_rootfs.sh b/y2020/vision/rootfs/modify_rootfs.sh
index 1cb8a39..289da9a 100755
--- a/y2020/vision/rootfs/modify_rootfs.sh
+++ b/y2020/vision/rootfs/modify_rootfs.sh
@@ -3,9 +3,8 @@
set -xe
IMAGE="2020-02-13-raspbian-buster-lite.img"
-BOOT_PARTITION="2020-02-13-raspbian-buster-lite.img.boot_partition"
-PARTITION="2020-02-13-raspbian-buster-lite.img.partition"
-HOSTNAME="pi-8971-1"
+BOOT_PARTITION="${IMAGE}.boot_partition"
+PARTITION="${IMAGE}.partition"
function target() {
HOME=/root/ USER=root sudo proot -0 -q qemu-arm-static -w / -r "${PARTITION}" "$@"
@@ -44,9 +43,9 @@
else
OFFSET="$(fdisk -lu "${IMAGE}" | grep "${IMAGE}2" | awk '{print 512*$2}')"
- if [[ "$(stat -c %s "${IMAGE}")" == 1849688064 ]]; then
+ if [[ "$(stat -c %s "${IMAGE}")" < 2000000000 ]]; then
echo "Growing image"
- dd if=/dev/zero bs=1M count=1024 >> "${IMAGE}"
+ dd if=/dev/zero bs=1G count=1 >> "${IMAGE}"
START="$(fdisk -lu "${IMAGE}" | grep "${IMAGE}2" | awk '{print $2}')"
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk "${IMAGE}"
diff --git a/y2020/vision/rootfs/target_configure.sh b/y2020/vision/rootfs/target_configure.sh
index 193f8b5..f761e84 100755
--- a/y2020/vision/rootfs/target_configure.sh
+++ b/y2020/vision/rootfs/target_configure.sh
@@ -83,5 +83,5 @@
systemctl enable ssh.service
systemctl enable frc971.service
-# Default us to pi-8971-1
-/root/bin/change_hostname.sh pi-8971-1
+# Default us to pi-971-1
+/root/bin/change_hostname.sh pi-971-1