2023-02-08 21:01:48 +00:00
|
|
|
#!/bin/bash
|
2017-07-03 03:01:04 +00:00
|
|
|
# Boot from a local disk installation
|
|
|
|
|
|
|
|
. /etc/functions
|
2018-12-06 23:24:28 +00:00
|
|
|
. /tmp/config
|
2017-07-03 03:01:04 +00:00
|
|
|
|
2017-07-18 17:44:02 +00:00
|
|
|
mount_boot()
|
|
|
|
{
|
2023-02-20 16:01:17 +00:00
|
|
|
TRACE "Under /bin/generic-init:mount_boot"
|
2017-07-18 17:44:02 +00:00
|
|
|
# Mount local disk if it is not already mounted
|
|
|
|
if ! grep -q /boot /proc/mounts ; then
|
|
|
|
mount -o ro /boot \
|
|
|
|
|| recovery "Unable to mount /boot"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Confirm we have a good TOTP unseal and ask the user for next choice
|
|
|
|
while true; do
|
|
|
|
echo "y) Default boot"
|
|
|
|
echo "n) TOTP does not match"
|
|
|
|
echo "r) Recovery boot"
|
|
|
|
echo "u) USB boot"
|
|
|
|
echo "m) Boot menu"
|
|
|
|
|
|
|
|
if ! confirm_totp "Boot mode"; then
|
|
|
|
recovery 'Failed to unseal TOTP'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$totp_confirm" = "r" ]; then
|
|
|
|
recovery "User requested recovery shell"
|
|
|
|
fi
|
|
|
|
|
2017-07-22 18:57:46 +00:00
|
|
|
if [ "$totp_confirm" = "n" ]; then
|
2017-07-18 17:44:02 +00:00
|
|
|
echo ""
|
|
|
|
echo "To correct clock drift: 'date -s HH:MM:SS'"
|
|
|
|
echo "and save it to the RTC: 'hwclock -w'"
|
|
|
|
echo "then reboot and try again"
|
|
|
|
echo ""
|
|
|
|
recovery "TOTP mismatch"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$totp_confirm" = "u" ]; then
|
|
|
|
exec /bin/usb-init
|
2017-07-22 18:57:46 +00:00
|
|
|
continue
|
2017-07-18 17:44:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$totp_confirm" = "m" ]; then
|
|
|
|
# Try to select a kernel from the menu
|
|
|
|
mount_boot
|
|
|
|
kexec-select-boot -m -b /boot -c "grub.cfg"
|
2017-07-22 18:57:46 +00:00
|
|
|
continue
|
2017-07-18 17:44:02 +00:00
|
|
|
fi
|
|
|
|
|
2017-07-22 18:57:46 +00:00
|
|
|
if [ "$totp_confirm" = "y" -o -n "$totp_confirm" ]; then
|
2017-07-18 17:44:02 +00:00
|
|
|
# Try to boot the default
|
|
|
|
mount_boot
|
2017-07-22 18:57:46 +00:00
|
|
|
kexec-select-boot -b /boot -c "grub.cfg" \
|
|
|
|
|| recovery "Failed default boot"
|
2017-07-18 17:44:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
2017-07-03 03:01:04 +00:00
|
|
|
|
2017-07-08 20:59:37 +00:00
|
|
|
recovery "Something failed during boot"
|