Reimplement grub-reboot to not depend on saved_entry. Use next_entry
variable for one time boot menu entry.
This commit is contained in:
parent
fa2923436b
commit
5945c2f849
4 changed files with 25 additions and 12 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2013-05-06 Andrey Borzenkov <arvidjaar@gmail.com>
|
||||||
|
|
||||||
|
Reimplement grub-reboot to not depend on saved_entry. Use next_entry
|
||||||
|
variable for one time boot menu entry.
|
||||||
|
|
||||||
2013-05-05 Bean <bean123ch@gmail.com>
|
2013-05-05 Bean <bean123ch@gmail.com>
|
||||||
|
|
||||||
* grub-core/commands/testspeed.c: New command testspeed.
|
* grub-core/commands/testspeed.c: New command testspeed.
|
||||||
|
|
|
@ -46,8 +46,6 @@ export TEXTDOMAINDIR="@localedir@"
|
||||||
usage () {
|
usage () {
|
||||||
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
|
gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self"
|
||||||
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
|
gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo
|
||||||
gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir"
|
|
||||||
echo
|
|
||||||
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
print_option_help "-h, --help" "$(gettext "print this message and exit")"
|
||||||
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
print_option_help "-v, --version" "$(gettext "print the version information and exit")"
|
||||||
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
|
dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
|
||||||
|
@ -129,17 +127,14 @@ fi
|
||||||
|
|
||||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||||
|
|
||||||
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
|
# Restore saved_entry if it was set by previous version
|
||||||
|
prev_saved_entry=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^prev_saved_entry=//p'`
|
||||||
if [ "$prev_saved_entry" ]; then
|
if [ "$prev_saved_entry" ]; then
|
||||||
$grub_editenv ${grubdir}/grubenv set prev_saved_entry="$prev_saved_entry"
|
$grub_editenv ${grubdir}/grubenv set saved_entry="$prev_saved_entry"
|
||||||
else
|
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
||||||
# We need some non-empty value for prev_saved_entry so that GRUB will
|
|
||||||
# recognise that grub-reboot has been used and restore the previous
|
|
||||||
# saved entry. "0" is the same as an empty value, i.e. the first menu
|
|
||||||
# entry.
|
|
||||||
$grub_editenv ${grubdir}/grubenv set prev_saved_entry=0
|
|
||||||
fi
|
fi
|
||||||
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
|
||||||
|
$grub_editenv ${grubdir}/grubenv set next_entry="$entry"
|
||||||
|
|
||||||
# Bye.
|
# Bye.
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -130,6 +130,7 @@ fi
|
||||||
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
|
||||||
|
|
||||||
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
$grub_editenv ${grubdir}/grubenv unset prev_saved_entry
|
||||||
|
$grub_editenv ${grubdir}/grubenv unset next_entry
|
||||||
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
$grub_editenv ${grubdir}/grubenv set saved_entry="$entry"
|
||||||
|
|
||||||
# Bye.
|
# Bye.
|
||||||
|
|
|
@ -51,13 +51,25 @@ if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
|
||||||
set default="${GRUB_DEFAULT_BUTTON}"
|
set default="${GRUB_DEFAULT_BUTTON}"
|
||||||
|
elif [ "\${next_entry}" ] ; then
|
||||||
|
set default="\${next_entry}"
|
||||||
|
set next_entry=
|
||||||
|
save_env next_entry
|
||||||
|
set boot_once=true
|
||||||
else
|
else
|
||||||
set default="${GRUB_DEFAULT}"
|
set default="${GRUB_DEFAULT}"
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
set default="${GRUB_DEFAULT}"
|
if [ "\${next_entry}" ] ; then
|
||||||
|
set default="\${next_entry}"
|
||||||
|
set next_entry=
|
||||||
|
save_env next_entry
|
||||||
|
set boot_once=true
|
||||||
|
else
|
||||||
|
set default="${GRUB_DEFAULT}"
|
||||||
|
fi
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
|
Loading…
Reference in a new issue