| 1 |
#! /bin/sh
|
| 2 |
|
| 3 |
# $Id$
|
| 4 |
#*********************************************************************
|
| 5 |
#
|
| 6 |
# make-fai-bootfloppy -- create a boot floppy for FAI
|
| 7 |
#
|
| 8 |
# This script is part of FAI (Fully Automatic Installation)
|
| 9 |
# (c) 2000-2001 by Thomas Lange, lange@informatik.uni-koeln.de
|
| 10 |
# Universitaet zu Koeln
|
| 11 |
#
|
| 12 |
#*********************************************************************
|
| 13 |
# This program is free software; you can redistribute it and/or modify
|
| 14 |
# it under the terms of the GNU General Public License as published by
|
| 15 |
# the Free Software Foundation; either version 2 of the License, or
|
| 16 |
# (at your option) any later version.
|
| 17 |
#
|
| 18 |
# This program is distributed in the hope that it will be useful, but
|
| 19 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 20 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 21 |
# General Public License for more details.
|
| 22 |
#
|
| 23 |
# A copy of the GNU General Public License is available as
|
| 24 |
# `/usr/share/common-licences/GPL' in the Debian GNU/Linux distribution
|
| 25 |
# or on the World Wide Web at http://www.gnu.org/copyleft/gpl.html. You
|
| 26 |
# can also obtain it by writing to the Free Software Foundation, Inc.,
|
| 27 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 28 |
#*********************************************************************
|
| 29 |
|
| 30 |
version="version 1.4.1, august 2001"
|
| 31 |
set -e
|
| 32 |
floppydev=/dev/fd0
|
| 33 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 34 |
die() {
|
| 35 |
|
| 36 |
echo -e $*
|
| 37 |
exit 99
|
| 38 |
}
|
| 39 |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 40 |
usage() {
|
| 41 |
|
| 42 |
cat <<EOF
|
| 43 |
make-fai-bootfloppy, create a boot floppy for FAI. $version
|
| 44 |
|
| 45 |
Copyright (C) 2000, 2001 by Thomas Lange
|
| 46 |
|
| 47 |
Usage: make-fai-bootfloppy [parameter]
|
| 48 |
|
| 49 |
-h print this message.
|
| 50 |
|
| 51 |
DESCRIPTION
|
| 52 |
Creates a boot floppy for booting a FAI install client.
|
| 53 |
No arguments are needed but you must be root.
|
| 54 |
All parameters are passed to the kernel via append in lilo.conf.
|
| 55 |
|
| 56 |
EXAMPLE
|
| 57 |
To make a boot floppy for my old SMC EtherCard Plus Elite 16T, I use
|
| 58 |
|
| 59 |
# make-fai-bootfloppy "reserve=0x300,32 ether=10,0x300,eth0"
|
| 60 |
|
| 61 |
EOF
|
| 62 |
exit 0
|
| 63 |
}
|
| 64 |
|
| 65 |
# - - - - - - - - - - - - - - - - - - - - - - - - - -
|
| 66 |
# main part
|
| 67 |
while getopts h opt ; do
|
| 68 |
case "$opt" in
|
| 69 |
h) usage ;;
|
| 70 |
esac
|
| 71 |
done
|
| 72 |
|
| 73 |
if [ "$UID" -ne 0 ]; then
|
| 74 |
echo "You must be root!"
|
| 75 |
exit 9
|
| 76 |
fi
|
| 77 |
|
| 78 |
# additional kernel parameter
|
| 79 |
params=$*
|
| 80 |
|
| 81 |
. /etc/fai.conf
|
| 82 |
|
| 83 |
grep -q ic_bootp $NFSROOT/boot/System.map-$KERNELVERSION && TYPE=BOOTP
|
| 84 |
grep -q ic_dhcp $NFSROOT/boot/System.map-$KERNELVERSION && TYPE=DHCP
|
| 85 |
|
| 86 |
[ "$TYPE" ] || die "Can't determine kernel boot protocol.\nMaybe there's no $NFSROOT/boot/System.map-$KERNELVERSION"
|
| 87 |
|
| 88 |
ndevices=0
|
| 89 |
devices=`egrep -v "lo:|^Inter-|^ face" /proc/net/dev | awk -F: '{print $1}'`
|
| 90 |
for dev in $devices; do
|
| 91 |
ndevices=$((ndevices+1))
|
| 92 |
done
|
| 93 |
[ $ndevices = 0 ] && die "No network interface found. Can't determine IP address."
|
| 94 |
if [ $ndevices = 1 ]; then
|
| 95 |
SERVERINTERFACE=$dev
|
| 96 |
else
|
| 97 |
while [ -z "$SERVERINTERFACE" ]; do
|
| 98 |
echo "Your machine has multiple network interfaces: $devices"
|
| 99 |
echo -n "Specify which one will be used for FAI (eg. eth1): "
|
| 100 |
read SERVERINTERFACE
|
| 101 |
done
|
| 102 |
fi
|
| 103 |
SERVERIP=`LC_ALL=C ifconfig $SERVERINTERFACE | perl -ne '/inet addr:([0-9\.]+)/ && print $1'`
|
| 104 |
echo "Using interface $SERVERINTERFACE with IP address: $SERVERIP"
|
| 105 |
unset SERVERINTERFACE ndevices devices dev
|
| 106 |
|
| 107 |
mke2fs -q -i 8192 -m 0 $floppydev || die "Can't create ext2 file system on $floppydev"
|
| 108 |
mount $floppydev /floppy || die "Can't mount floppy $floppydev"
|
| 109 |
cp -ad $NFSROOT/boot /floppy
|
| 110 |
mkdir -p /floppy/etc
|
| 111 |
ln -s boot/vmlinuz-$KERNELVERSION /floppy/vmlinuz
|
| 112 |
[ -L /floppy/boot/boot.b ] && {
|
| 113 |
# since lilo 21.5, boot.b is a link
|
| 114 |
rm /floppy/boot/boot.b
|
| 115 |
ln -s /floppy/boot/boot-compat.b /floppy/boot/boot.b
|
| 116 |
}
|
| 117 |
|
| 118 |
cat > /floppy/etc/lilo.conf <<-EOF
|
| 119 |
boot=$floppydev
|
| 120 |
root=$NFSROOT/dev/boot255
|
| 121 |
install=/floppy/boot/boot.b
|
| 122 |
map=/floppy/boot/map
|
| 123 |
append="NFSROOT=$SERVERIP:$NFSROOT $params"
|
| 124 |
delay=10
|
| 125 |
compact
|
| 126 |
image=/floppy/vmlinuz
|
| 127 |
label=FAI-$TYPE
|
| 128 |
read-only
|
| 129 |
EOF
|
| 130 |
|
| 131 |
echo now writing boot data to floppy
|
| 132 |
$NFSROOT/sbin/lilo -C /floppy/etc/lilo.conf
|
| 133 |
cd /
|
| 134 |
umount /floppy
|
| 135 |
|
| 136 |
cat <<EOF
|
| 137 |
FAI boot floppy created.
|
| 138 |
boot protocol : $TYPE
|
| 139 |
nfsroot : $SERVERIP:$NFSROOT
|
| 140 |
parameters : $params
|
| 141 |
The kernel configuration is $NFSROOT/boot/config-$KERNELVERSION-$TYPE.
|
| 142 |
EOF
|