mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-04 11:51:14 +02:00
If a user or old software creates the flag file on the old CoreOS location, nothing would happen. Check the old location, too, so that Ignition is rerun.
164 lines
5.2 KiB
INI
164 lines
5.2 KiB
INI
# Main GRUB config
|
|
|
|
# Set the prefix back to the correct value after we're done with memdisk
|
|
set prefix=($root)/flatcar/grub
|
|
|
|
# Load any and all video drivers.
|
|
# Required under UEFI to boot Linux with a working console.
|
|
insmod all_video
|
|
|
|
# Default menuentry id and boot timeout
|
|
set default="flatcar"
|
|
set timeout=1
|
|
|
|
# Default kernel args for root filesystem, console, and Flatcar.
|
|
set linux_root="root=LABEL=ROOT"
|
|
set linux_console=""
|
|
set first_boot=""
|
|
set randomize_disk_guid=""
|
|
set oem_id=""
|
|
|
|
# Anything else the OEM adds should use this variable.
|
|
set linux_append=""
|
|
|
|
set secure_boot="0"
|
|
|
|
if [ "$grub_platform" = "efi" ]; then
|
|
getenv -e SecureBoot -g 8be4df61-93ca-11d2-aa0d-00e098032b8c -b sb
|
|
getenv -e SetupMode -g 8be4df61-93ca-11d2-aa0d-00e098032b8c -b setupmode
|
|
if [ "$sb" = "01" -a "$setupmode" = "00" ]; then
|
|
set secure_boot="1"
|
|
getenv -e NetBootVerificationKey -g b8ade7d5-d400-4213-8d15-d47be0a621bf -b gpgpubkey
|
|
if [ "$gpgpubkey" != "" ]; then
|
|
trust_var gpgpubkey
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
if [ "$net_default_server" != "" ]; then
|
|
smbios --type 1 --get-uuid 8 --set uuid
|
|
smbios --type 1 --get-string 7 --set serial
|
|
set mac=$net_default_mac
|
|
# Re-DHCP as grub to get the API endpoint
|
|
net_bootp $net_default_interface
|
|
# This is awful, but grub doesn't support a nice way to do this
|
|
for i in "$net_efinet0_dhcp_boot_file" "$net_efinet1_dhcp_boot_file" "$net_efinet2_dhcp_boot_file" "$net_efinet3_dhcp_boot_file" "$net_efinet4_dhcp_boot_file" "$net_efinet5_dhcp_boot_file" "$net_efinet6_dhcp_boot_file" "$net_efinet7_dhcp_boot_file" "$net_efinet8_dhcp_boot_file" "$net_efinet9_dhcp_boot_file"; do
|
|
if [ "$i" != "" ]; then
|
|
set endpoint="$i"
|
|
break
|
|
fi
|
|
done
|
|
if [ "$endpoint" != "" ]; then
|
|
set url="${endpoint}?uuid=$uuid&serial=$serial&mac=$mac"
|
|
if [ "$gpgpubkey" != "" ]; then
|
|
set check_signatures="enforce"
|
|
fi
|
|
configfile $url
|
|
fi
|
|
fi
|
|
|
|
# Search for the OEM partition, load additional configuration if found.
|
|
if [ "$secure_boot" = "0" ]; then
|
|
search --no-floppy --set oem --part-label OEM --hint "$root"
|
|
if [ -n "$oem" -a -f "($oem)/grub.cfg" ]; then
|
|
source "($oem)/grub.cfg"
|
|
fi
|
|
fi
|
|
|
|
# Determine if this is a first boot.
|
|
if [ -f "($root)/flatcar/first_boot" ]; then
|
|
set first_boot="flatcar.first_boot=detected"
|
|
fi
|
|
if [ -f "($root)/coreos/first_boot" ]; then
|
|
set first_boot="flatcar.first_boot=detected"
|
|
fi
|
|
|
|
# Determine if the disk GUID needs to be randomized.
|
|
search --no-floppy --set randomize_disk_guid \
|
|
--disk-uuid 00000000-0000-0000-0000-000000000001
|
|
if [ -n "$randomize_disk_guid" ]; then
|
|
set randomize_disk_guid="flatcar.randomize_disk_guid=00000000-0000-0000-0000-000000000001"
|
|
fi
|
|
|
|
set oem=""
|
|
if [ -n "$oem_id" ]; then
|
|
set oem="flatcar.oem.id=$oem_id"
|
|
fi
|
|
|
|
# If no specific console has been set by the OEM then select based on
|
|
# platform, most systems use vga text as primary and ttyS0 as secondary.
|
|
if [ -z "$linux_console" ]; then
|
|
if [ "$grub_platform" = pc ]; then
|
|
set linux_console="console=ttyS0,115200n8 console=tty0"
|
|
serial com0 --speed=115200 --word=8 --parity=no
|
|
terminal_input console serial_com0
|
|
terminal_output console serial_com0
|
|
elif [ "$grub_platform" = efi ]; then
|
|
if [ "$grub_cpu" = arm64 ]; then
|
|
set linux_console="console=ttyAMA0,115200n8"
|
|
else
|
|
set linux_console="console=ttyS0,115200n8 console=tty0"
|
|
fi
|
|
elif [ "$grub_platform" = xen ]; then
|
|
set linux_console="console=hvc0"
|
|
fi
|
|
fi
|
|
|
|
set extra_options=""
|
|
if [ "$grub_cpu" = arm64 ]; then
|
|
set extra_options="acpi=force"
|
|
fi
|
|
|
|
set suf=""
|
|
|
|
# UEFI uses linuxefi/initrdefi instead of linux/initrd except for arm64
|
|
if [ "$grub_platform" = efi ]; then
|
|
if [ "$grub_cpu" != arm64 ]; then
|
|
set suf="efi"
|
|
fi
|
|
fi
|
|
|
|
# Assemble the options applicable to all the kernels below
|
|
set linux_cmdline="rootflags=rw mount.usrflags=ro consoleblank=0 $linux_root $linux_console $first_boot $randomize_disk_guid $extra_options $oem $linux_append"
|
|
|
|
# Re-implement grub_abort() since no command exposes it.
|
|
function abort {
|
|
echo
|
|
echo "Aborted. Press enter to exit GRUB."
|
|
read anything
|
|
exit
|
|
}
|
|
|
|
# Select the kernel and usr partition to boot.
|
|
function gptprio {
|
|
# TODO: device name is no longer needed, should make it optional...
|
|
gptprio.next -d usr_device -u usr_uuid
|
|
if [ $? -ne 0 -o -z "$usr_uuid" ]; then
|
|
echo
|
|
echo "Reading or updating the GPT failed!"
|
|
echo "Please file a bug with any messages above to Flatcar:"
|
|
echo " https://issues.flatcar-linux.org"
|
|
abort
|
|
fi
|
|
|
|
set gptprio_cmdline="@@MOUNTUSR@@=PARTUUID=$usr_uuid"
|
|
if [ "$usr_uuid" = "7130c94a-213a-4e5a-8e26-6cce9662f132" ]; then
|
|
set gptprio_kernel="/flatcar/vmlinuz-a"
|
|
else
|
|
set gptprio_kernel="/flatcar/vmlinuz-b"
|
|
fi
|
|
}
|
|
|
|
menuentry "Flatcar default" --id=flatcar --unrestricted {
|
|
gptprio
|
|
linux$suf $gptprio_kernel $gptprio_cmdline $linux_cmdline
|
|
}
|
|
|
|
menuentry "Flatcar USR-A" --id=flatcar-a {
|
|
linux$suf /flatcar/vmlinuz-a @@MOUNTUSR@@=PARTLABEL=USR-A $linux_cmdline
|
|
}
|
|
|
|
menuentry "Flatcar USR-B" --id=flatcar-b {
|
|
linux$suf /flatcar/vmlinuz-b @@MOUNTUSR@@=PARTLABEL=USR-B $linux_cmdline
|
|
}
|