1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
# Snapd-Boot-Config-Edition: 3
set default=0
set timeout=3
set timeout_style=hidden
# load only kernel_status and kernel command line variables set by snapd from
# the bootenv
load_env --file /EFI/ubuntu/grubenv kernel_status snapd_extra_cmdline_args snapd_full_cmdline_args
set snapd_static_cmdline_args='panic=-1'
if [ "$grub_cpu" = "x86_64" ]; then
set snapd_static_cmdline_args='console=ttyS0,115200n8 console=tty1 panic=-1'
fi
set cmdline_args="$snapd_static_cmdline_args $snapd_extra_cmdline_args"
if [ -n "$snapd_full_cmdline_args" ]; then
set cmdline_args="$snapd_full_cmdline_args"
fi
set kernel=kernel.efi
if [ "$kernel_status" = "try" ]; then
# a new kernel got installed
set kernel_status="trying"
save_env kernel_status
# run fallback (menu entry #1) if we cannot start the kernel
set fallback=1
# use try-kernel.efi
set kernel=try-kernel.efi
elif [ "$kernel_status" = "trying" ]; then
# nothing cleared the "trying snap" so the boot failed
# we clear the mode and boot normally
set kernel_status=""
save_env kernel_status
elif [ -n "$kernel_status" ]; then
# ERROR invalid kernel_status state, reset to empty
echo "invalid kernel_status!!!"
echo "resetting to empty"
set kernel_status=""
save_env kernel_status
fi
menuentry "Run Ubuntu Core" {
# use $prefix because the symlink manipulation at runtime for kernel snap
# upgrades, etc. should only need the /boot/grub/ directory, not the
# /EFI/ubuntu/ directory
chainloader $prefix/$kernel snapd_recovery_mode=run $cmdline_args
}
menuentry "Fallback on failed update" {
# kernel_status has already been set to "trying", rebooting now
# will fail the pending kernel update. Note that we cannot simply
# chainload the fallback kernel as TPM measurements need to be
# cleaned-up to be able to unseal the key.
echo "Cannot start new kernel - booting previous one"
reboot
}
|