Hi all,
attached is a shell script to create a grub boot floppy, I'd like to
have it added to CVS.
the configure.in will need to be changed so it finds "dd" and the
grub-floppy.in will need to be changed to use the variable which
configure.in stores the location of dd and of course the Makefile.am
will need to be changed in the utils dir to build the grub-floppy
script.
Not that much really.
Thanks
--
Jason Thomas Phone: +61 2 6257 7111
System Administrator - UID 0 Fax: +61 2 6257 7311
tSA Consulting Group Pty. Ltd. Mobile: 0418 29 66 81
1 Hall Street Lyneham ACT 2602 http://www.topic.com.au/
#!/bin/sh
# Create GRUB boot floppy.
# Copyright (C) 2001 Jason Thomas <[EMAIL PROTECTED]>
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# Initialize some variables.
dd=/bin/dd
pkgdatadir=${datadir}/${PACKAGE}/${host_cpu}-${host_vendor}
stage1=$pkgdatadir/stage1
stage2=$pkgdatadir/stage2
# I like functions.
abort () {
echo -e "\n$@\n" >&2
exit 1
}
checkfiles () {
[ -x "$DD" ] || abort "Can't find $DD, aborting"
[ -f "$STAGE1" ] || abort "Can't find $STAGE1, aborting"
[ -f "$STAGE2" ] || abort "Can't find $STAGE2, aborting"
}
usage () {
cat <<EOF
Usage: $0 [OPTION] install_device
Create GRUB boot floppy.
-h, --help print this message and exit
EOF
exit 1
}
checkdevice () {
[ -z "$1" ] && abort "checkdevice() takes block device as parameter"
[ -b "$1" ] || abort "$1 is not a block device, aborting"
[ -w "$1" ] || abort "$1 is not a writeable block device, aborting"
}
questiondevice () {
[ -z "$1" ] && abort "questiondevice() takes block device as parameter"
echo "You are about to overwrite the boot sector of the following device:"
echo "$1"
echo -n "Are you sure you want to take this action (y/N) "
read answer
case "$answer" in
y* | Y*)
# let this fall through to the next function
;;
*)
abort "Not continuing as you wish"
;;
esac
}
createfloppy () {
[ -z "$1" ] && abort "createfloppy() takes block device as parameter"
echo -e "Creating grub boot floppy now, please be patient ...\n"
# heres where we actually create the floppy :-p
$dd if="$stage1" of="$1" bs="512" count="1"
$dd if="$stage2" of="$1" bs="512" seek="1"
echo -e "\nThat's All Folks!"
}
# test we have the necessary files first
checkfiles
case "$1" in
-h | --help)
usage
;;
*)
if [ -z "$1" ] ; then
usage
else
checkdevice "$1"
questiondevice "$1"
createfloppy "$1"
fi
;;
esac
exit 0
PGP signature