feat: automate RPi4 network boot transition
This commit is contained in:
parent
5ea8149b99
commit
7d8ed45707
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue