From 7d8ed457078cdae0aad20432afd2b5ea90ae2dad Mon Sep 17 00:00:00 2001 From: "juvenal.diaz" Date: Sat, 24 Oct 2026 09:06:22 -0600 Subject: [PATCH] feat: automate RPi4 network boot transition --- scripts/rpi4-image-install | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/rpi4-image-install b/scripts/rpi4-image-install index 8fb5b90..c77251f 100755 --- a/scripts/rpi4-image-install +++ b/scripts/rpi4-image-install @@ -35,6 +35,31 @@ EOF [[ "${2:-}" == "--yes" ]] || { echo "Use: scripts/rpi4-image-install apply --yes" >&2; exit 2; } [[ -n "${public_key}" ]] || { echo "An SSH public key is required" >&2; exit 2; } root_source="$(ssh -i "${rpi_key}" -o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=accept-new "${rpi_user}@${rpi_host}" 'findmnt -no SOURCE /')" + if [[ "${root_source}" != /dev/nfs* && "${root_source}" != *:* ]]; then + if [[ ! -t 0 ]]; then + echo "Remote EEPROM modification requires an interactive confirmation terminal." >&2 + exit 2 + fi + printf 'This will change %s EEPROM BOOT_ORDER from SD-first to network-first and reboot it. Type CHANGE-RPI4-BOOT to continue: ' "${rpi_host}" >&2 + read -r confirmation + [[ "${confirmation}" == "CHANGE-RPI4-BOOT" ]] || { echo "Confirmation did not match; aborting." >&2; exit 2; } + ssh -i "${rpi_key}" -o BatchMode=yes "${rpi_user}@${rpi_host}" 'cat >/tmp/jeannie-eeprom-editor <<"EDITOR" +#!/bin/sh +sed -i "s/^BOOT_ORDER=.*/BOOT_ORDER=0xf2/" "$1" +EDITOR +chmod 0755 /tmp/jeannie-eeprom-editor +sudo env EDITOR=/tmp/jeannie-eeprom-editor VISUAL=/tmp/jeannie-eeprom-editor rpi-eeprom-config --edit +rm -f /tmp/jeannie-eeprom-editor +sudo reboot' || true + echo "Waiting for the Pi to return on its Debian NFS root..." + for _ in $(seq 1 90); do + sleep 2 + root_source="$(ssh -i "${rpi_key}" -o BatchMode=yes -o ConnectTimeout=3 "${rpi_user}@${rpi_host}" 'findmnt -no SOURCE /' 2>/dev/null || true)" + if [[ "${root_source}" == /dev/nfs* || "${root_source}" == *:* ]]; then + break + fi + done + fi [[ "${root_source}" == /dev/nfs* || "${root_source}" == *:* ]] || { echo "Refusing image: Pi root is ${root_source}, not NFS" >&2; exit 2; } mkdir -p "${cache_dir}" image_file="${cache_dir}/raspios_lite_arm64_latest.img.xz"