use the override options if specified
[AROS.git] / arch / all-pc / boot / grub / util / grub-set-default.in
blobdc5b783fd5e010bb519482c27b36c65cf547b7fe
1 #! /bin/sh
3 # Set a default boot entry for GRUB
4 # Copyright (C) 2004 Free Software Foundation, Inc.
6 # This file is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 # Initialize some variables.
21 PACKAGE=@PACKAGE@
22 VERSION=@VERSION@
24 rootdir=
25 entry=
27 # Usage: usage
28 # Print the usage.
29 usage () {
30 cat <<EOF
31 Usage: grub-set-default [OPTION] entry
32 Set the default boot entry for GRUB.
34 -h, --help print this message and exit
35 -v, --version print the version information and exit
36 --root-directory=DIR Use the directory DIR instead of the root directory
38 ENTRY is a number or the special keyword \`default\'.
40 Report bugs to <bug-grub@gnu.org>.
41 EOF
44 # Check the arguments.
45 for option in "$@"; do
46 case "$option" in
47 -h | --help)
48 usage
49 exit 0 ;;
50 -v | --version)
51 echo "grub-set-default (GNU GRUB ${VERSION})"
52 exit 0 ;;
53 --root-directory=*)
54 rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
55 -*)
56 echo "Unrecognized option \`$option'" 1>&2
57 usage
58 exit 1
61 if test "x$entry" != x; then
62 echo "More than one entries?" 1>&2
63 usage
64 exit 1
66 # We don't care about what the user specified actually.
67 entry="${option}" ;;
68 esac
69 done
71 if test "x$entry" = x; then
72 echo "entry not specified." 1>&2
73 usage
74 exit 1
77 # Determine the GRUB directory. This is different among OSes.
78 grubdir=${rootdir}/boot/grub
79 if test -d ${grubdir}; then
81 else
82 grubdir=${rootdir}/grub
83 if test -d ${grubdir}; then
85 else
86 echo "No GRUB directory found under ${rootdir}/" 1>&2
87 exit 1
91 file=${grubdir}/default
92 if test -f ${file}; then
93 chmod 0600 ${file}
94 rm -f ${file}
96 cat <<EOF > $file
97 $entry
108 # WARNING: If you want to edit this file directly, do not remove any line
109 # from this file, including this warning. Using \`grub-set-default\' is
110 # strongly recommended.
113 # Bye.
114 exit 0