]>
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}`
33 grubdir
=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
39 Usage: $self [OPTION] entry
40 Set the default boot entry for GRUB, for the next boot only.
42 -h, --help print this message and exit
43 -v, --version print the version information and exit
44 --boot-directory=DIR expect GRUB images under the directory DIR/@grubdirname@
45 instead of the $grubdir directory
47 ENTRY is a number or a menu item title.
49 Report bugs to <bug-grub@gnu.org>.
57 if test $# -eq 0; then
58 echo "$0: option requires an argument -- '$opt'" 1>&2
64 # Check the arguments.
75 echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
78 # Accept for compatibility
80 rootdir
=`argument $option "$@"`; shift ;;
82 rootdir
=`echo "$option" | sed 's/--root-directory=//'` ;;
85 bootdir
=`argument $option "$@"`; shift;;
87 bootdir
=`echo "$option" | sed 's/--boot-directory=//'` ;;
90 echo "Unrecognized option \`$option'" 1>&2
95 if test "x$entry" != x
; then
96 echo "More than one entry?" 1>&2
104 if test "x$entry" = x
; then
105 echo "entry not specified." 1>&2
110 if [ -z "$bootdir" ]; then
111 # Default bootdir if bootdir not initialized.
112 bootdir
=/@bootdirname@
114 if [ -n "$rootdir" ] ; then
115 # Initialize bootdir if rootdir was initialized.
116 bootdir
=${rootdir}/@bootdirname@
120 grubdir
=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
122 prev_saved_entry
=`$grub_editenv ${grubdir}/grubenv list | sed -n 's/^saved_entry=//p'`
123 if [ "$prev_saved_entry" ]; then
124 $grub_editenv ${grubdir}/grubenv
set prev_saved_entry
="$prev_saved_entry"
126 # We need some non-empty value for prev_saved_entry so that GRUB will
127 # recognise that grub-reboot has been used and restore the previous
128 # saved entry. "0" is the same as an empty value, i.e. the first menu
130 $grub_editenv ${grubdir}/grubenv
set prev_saved_entry
=0
132 $grub_editenv ${grubdir}/grubenv
set saved_entry
="$entry"