1N/A#! /bin/sh
1N/A
1N/A# Set a default boot entry for GRUB
1N/A# Copyright (C) 2004 Free Software Foundation, Inc.
1N/A#
1N/A# This file is free software; you can redistribute it and/or modify it
1N/A# under the terms of the GNU General Public License as published by
1N/A# the Free Software Foundation; either version 2 of the License, or
1N/A# (at your option) any later version.
1N/A#
1N/A# This program is distributed in the hope that it will be useful, but
1N/A# WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1N/A# General Public License for more details.
1N/A#
1N/A# You should have received a copy of the GNU General Public License
1N/A# along with this program; if not, write to the Free Software
1N/A# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1N/A
1N/A# Initialize some variables.
1N/APACKAGE=@PACKAGE@
1N/AVERSION=@VERSION@
1N/A
1N/Arootdir=
1N/Aentry=
1N/A
1N/A# Usage: usage
1N/A# Print the usage.
1N/Ausage () {
1N/A cat <<EOF
1N/AUsage: grub-set-default [OPTION] entry
1N/ASet the default boot entry for GRUB.
1N/A
1N/A -h, --help print this message and exit
1N/A -v, --version print the version information and exit
1N/A --root-directory=DIR Use the directory DIR instead of the root directory
1N/A
1N/AENTRY is a number or the special keyword \`default\'.
1N/A
1N/AReport bugs to <bug-grub@gnu.org>.
1N/AEOF
1N/A}
1N/A
1N/A# Check the arguments.
1N/Afor option in "$@"; do
1N/A case "$option" in
1N/A -h | --help)
1N/A usage
1N/A exit 0 ;;
1N/A -v | --version)
1N/A echo "grub-set-default (GNU GRUB ${VERSION})"
1N/A exit 0 ;;
1N/A --root-directory=*)
1N/A rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
1N/A -*)
1N/A echo "Unrecognized option \`$option'" 1>&2
1N/A usage
1N/A exit 1
1N/A ;;
1N/A *)
1N/A if test "x$entry" != x; then
1N/A echo "More than one entries?" 1>&2
1N/A usage
1N/A exit 1
1N/A fi
1N/A # We don't care about what the user specified actually.
1N/A entry="${option}" ;;
1N/A esac
1N/Adone
1N/A
1N/Aif test "x$entry" = x; then
1N/A echo "entry not specified." 1>&2
1N/A usage
1N/A exit 1
1N/Afi
1N/A
1N/A# Determine the GRUB directory. This is different among OSes.
1N/Agrubdir=${rootdir}/boot/grub
1N/Aif test -d ${grubdir}; then
1N/A :
1N/Aelse
1N/A grubdir=${rootdir}/grub
1N/A if test -d ${grubdir}; then
1N/A :
1N/A else
1N/A echo "No GRUB directory found under ${rootdir}/" 1>&2
1N/A exit 1
1N/A fi
1N/Afi
1N/A
1N/Afile=${grubdir}/default
1N/Aif test -f ${file}; then
1N/A chmod 0600 ${file}
1N/A rm -f ${file}
1N/Afi
1N/Acat <<EOF > $file
1N/A$entry
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A#
1N/A# WARNING: If you want to edit this file directly, do not remove any line
1N/A# from this file, including this warning. Using \`grub-set-default\' is
1N/A# strongly recommended.
1N/AEOF
1N/A
1N/A# Bye.
1N/Aexit 0