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