Description: Add configure option to bypass boot menu if possible If other operating systems are installed, then automatically unhide the menu. Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus if available to check whether Shift is pressed. If it is, show the menu, otherwise boot immediately. If keystatus is not available, then fall back to a short delay interruptible with Escape. . This may or may not remain Ubuntu-specific, although it's not obviously wanted upstream. It implements a requirement of https://wiki.ubuntu.com/DesktopExperienceTeam/KarmicBootExperienceDesignSpec#Bootloader. . If the previous boot failed (defined as failing to get to the end of one of the normal runlevels), then show the boot menu regardless. Author: Colin Watson Author: Richard Laager Forwarded: no Last-Update: 2013-11-13 Index: b/configure.ac =================================================================== --- a/configure.ac +++ b/configure.ac @@ -1087,6 +1087,17 @@ fi AC_SUBST([QUIET_BOOT]) +AC_ARG_ENABLE([quick-boot], + [AS_HELP_STRING([--enable-quick-boot], + [bypass boot menu if possible (default=no)])], + [], [enable_quick_boot=no]) +if test x"$enable_quick_boot" = xyes ; then + QUICK_BOOT=1 +else + QUICK_BOOT=0 +fi +AC_SUBST([QUICK_BOOT]) + LIBS="" AC_SUBST([FONT_SOURCE]) Index: b/docs/grub.texi =================================================================== --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1289,6 +1289,15 @@ Each module will be loaded as early as possible, at the start of @file{grub.cfg}. +@item GRUB_RECORDFAIL_TIMEOUT +If this option is set, it overrides the default recordfail setting. The +default setting is -1, which causes GRUB to wait for user input. This option +should be set on headless and appliance systems where access to a console is +restricted or limited. + +This option is only effective when GRUB was configured with the +@option{--enable-quick-boot} option. + @end table For more detailed customisation of @command{grub-mkconfig}'s output, you may Index: b/util/grub-mkconfig.in =================================================================== --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -228,7 +228,8 @@ GRUB_INIT_TUNE \ GRUB_SAVEDEFAULT \ GRUB_ENABLE_CRYPTODISK \ - GRUB_BADRAM + GRUB_BADRAM \ + GRUB_RECORDFAIL_TIMEOUT if test "x${grub_cfg}" != "x"; then rm -f "${grub_cfg}.new" Index: b/util/grub.d/00_header.in =================================================================== --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -23,6 +23,8 @@ exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" grub_lang=`echo $LANG | cut -d . -f 1` +grubdir="`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`" +quick_boot="@QUICK_BOOT@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" @@ -46,6 +48,7 @@ cat << EOF if [ -s \$prefix/grubenv ]; then + set have_grubenv=true load_env fi EOF @@ -86,7 +89,31 @@ save_env saved_entry fi } +EOF + +if [ "$quick_boot" = 1 ]; then + cat < /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then # missing os-prober and/or linux-boot-prober + adjust_timeout exit 0 fi @@ -43,10 +103,12 @@ OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`" if [ -z "${OSPROBED}" ] ; then # empty os-prober output, nothing doing + adjust_timeout exit 0 fi osx_entry() { + found_other_os=1 if [ x$2 = x32 ]; then # TRANSLATORS: it refers to kernel architecture (32-bit) bitstr="$(gettext "(32-bit)")" @@ -146,6 +208,7 @@ ;; esac + found_other_os=1 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { @@ -169,6 +232,7 @@ EOF ;; efi) + found_other_os=1 EFIPATH=${DEVICE#*@} DEVICE=${DEVICE%@*} cat << EOF @@ -211,6 +275,7 @@ [ "${prepare_boot_cache}" ] || continue fi + found_other_os=1 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" recovery_params="$(echo "${LPARAMS}" | grep 'single\|recovery')" || true counter=1 @@ -277,6 +342,7 @@ osx_entry xnu_kernel64 64 ;; hurd) + found_other_os=1 onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' { @@ -309,3 +375,5 @@ ;; esac done + +adjust_timeout