]>
git.proxmox.com Git - grub2.git/blob - util/grub-reboot.in
3 # Set a default boot entry for GRUB, for the next boot only.
4 # Copyright (C) 2004,2009 Free Software Foundation, Inc.
6 # GRUB is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GRUB is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 # Initialize some variables.
20 transform
="@program_transform_name@"
23 exec_prefix
=@exec_prefix@
25 PACKAGE_NAME
=@PACKAGE_NAME@
26 PACKAGE_VERSION
=@PACKAGE_VERSION@
30 grub_editenv
=${bindir}/`echo grub-editenv | sed ${transform}`
37 Usage: $self [OPTION] entry
38 Set the default boot entry for GRUB, for the next boot only.
40 -h, --help print this message and exit
41 -v, --version print the version information and exit
42 --root-directory=DIR expect GRUB images under the directory DIR
43 instead of the root directory
45 ENTRY is a number or a menu item title.
47 Report bugs to <bug-grub@gnu.org>.
51 # Check the arguments.
52 for option
in "$@"; do
58 echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
61 rootdir
=`echo "$option" | sed 's/--root-directory=//'` ;;
63 echo "Unrecognized option \`$option'" 1>&2
68 if test "x$entry" != x
; then
69 echo "More than one entry?" 1>&2
77 if test "x$entry" = x
; then
78 echo "entry not specified." 1>&2
83 # Initialize these directories here, since ROOTDIR was initialized.
86 # Because /boot is used for the boot block in NetBSD and OpenBSD, use /grub
87 # instead of /boot/grub.
88 grub_prefix
=`echo /grub | sed ${transform}`
92 # Use /boot/grub by default.
93 bootdir
=${rootdir}/boot
97 grubdir
=${bootdir}/`echo grub | sed ${transform}`
99 prev_saved_entry
=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
100 if [ "$prev_saved_entry" ]; then
101 $grub_editenv ${grubdir}/grubenv
set prev_saved_entry
="$prev_saved_entry"
103 # We need some non-empty value for prev_saved_entry so that GRUB will
104 # recognise that grub-reboot has been used and restore the previous
105 # saved entry. "0" is the same as an empty value, i.e. the first menu
107 $grub_editenv ${grubdir}/grubenv
set prev_saved_entry
=0
109 $grub_editenv ${grubdir}/grubenv
set saved_entry
="$entry"