/[fai]/trunk/scripts/make-fai-bootfloppy
ViewVC logotype

Contents of /trunk/scripts/make-fai-bootfloppy

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations) (download)
Tue Apr 9 08:06:57 2002 UTC (11 years, 1 month ago) by lange
File size: 5857 byte(s)
added option -s
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-2002 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.7, february 2001"
31 set -e
32 MKIMAGE=0
33 floppydev=/dev/fd0
34 mountopts=""
35 trap "umount_dirs" EXIT
36 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 umount_dirs() {
38 cd /
39 umount /floppy
40 }
41 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42 die() {
43
44 echo -e "$@"
45 exit 99
46 }
47 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48 determine_kernel_version() {
49
50 local num all
51 all=$(ls $NFSROOT/boot/System.map-*)
52 if [ `echo $all | wc -l ` = 1 ]; then
53 KERNELVERSION=$(echo "kernel version $all" | sed -e 's#.*/System.map-##')
54 else
55 die "Can't determine kernel version for $all"
56 fi
57 }
58 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 usage() {
60
61 cat <<EOF
62 make-fai-bootfloppy, create a boot floppy for FAI. $version
63
64 Copyright (C) 2000, 2001 by Thomas Lange
65
66 Usage: make-fai-bootfloppy [parameter]
67
68 -h print this message.
69 -s host use a static ip for host (try to get from DNS)
70 -f file make a 1440k floppy image
71
72 DESCRIPTION
73 Creates a boot floppy for booting a FAI install client.
74 No arguments are needed but you must be root.
75 All parameters are passed to the kernel via append in lilo.conf.
76
77 EXAMPLE
78 To make a boot floppy for my old SMC EtherCard Plus Elite 16T, I use
79
80 # make-fai-bootfloppy "reserve=0x300,32 ether=10,0x300,eth0"
81
82 EOF
83 exit 0
84 }
85
86 # - - - - - - - - - - - - - - - - - - - - - - - - - -
87 # main part
88 while getopts "f:s:h" opt ; do
89 case "$opt" in
90 h) usage ;;
91 f) MKIMAGE=1; floppydev="$OPTARG";;
92 s) TARGETHOST="$OPTARG" ;;
93 ?) echo "Error parsing arguments"; exit 1;;
94 esac
95 done
96 shift `expr $OPTIND - 1`
97
98 if [ "$UID" -ne 0 ]; then
99 echo "You must be root!"
100 exit 9
101 fi
102
103 # additional kernel parameter
104 params="$@"
105
106 . /etc/fai/fai.conf
107
108 determine_kernel_version
109 grep -q ic_bootp $NFSROOT/boot/System.map-$KERNELVERSION && TYPE=BOOTP
110 grep -q ic_dhcp $NFSROOT/boot/System.map-$KERNELVERSION && TYPE=DHCP
111
112 [ "$TYPE" ] || die "Can't determine kernel boot protocol.\nMaybe there's no $NFSROOT/boot/System.map-$KERNELVERSION"
113
114 ndevices=0
115 devices=`egrep -v "lo:|^Inter-|^ face" /proc/net/dev | awk -F: '{print $1}'`
116 for dev in $devices; do
117 ndevices=$(($ndevices+1))
118 done
119 [ $ndevices = 0 ] && die "No network interface found. Can't determine IP address."
120 if [ $ndevices = 1 ]; then
121 SERVERINTERFACE=$dev
122 else
123 while [ -z "$SERVERINTERFACE" ]; do
124 echo "Your machine has multiple network interfaces: $devices"
125 echo -n "Specify which one will be used for FAI (eg. eth1): "
126 read SERVERINTERFACE
127 done
128 fi
129 SERVERIP=`LC_ALL=C ifconfig $SERVERINTERFACE | perl -ne '/inet addr:([0-9\.]+)/ && print $1'`
130 echo "Using interface $SERVERINTERFACE with IP address: $SERVERIP"
131
132 if [ -n "${TARGETHOST}" ] ; then
133 BROADCAST=`LC_ALL=C ifconfig $SERVERINTERFACE | perl -ne '/Bcast:([0-9\.]+)/ && print $1'`
134 NETMASK=`LC_ALL=C ifconfig $SERVERINTERFACE | perl -ne '/Mask:([0-9\.]+)/ && print $1'`
135 GATEWAY=`LC_ALL=C route -n | grep '^0\.0\.0\.0' | awk '{ print $2 }'`
136 TARGETIP=`host -t a ${TARGETHOST} 2> /dev/null | awk '{print $3}'`
137 params="ip=${TARGETIP}:${SERVERIP}:${GATEWAY}:${NETMASK}:${TARGETHOST}::off $params"
138 fi
139
140 unset SERVERINTERFACE ndevices devices dev BROADCAST NETMASK GATEWAY TARGETIP
141
142 if [ $MKIMAGE -eq 1 ]; then
143 dd if=/dev/zero of=$floppydev bs=1024 count=1440
144 mountopts="$mountopts -o loop"
145 mkfsopt=-F
146 fi
147
148 mke2fs $mkfsopt -q -i 8192 -m 0 $floppydev || die "Can't create ext2 file system on $floppydev"
149 mount $mountopts $floppydev /floppy || die "Can't mount floppy $floppydev"
150 mkdir /floppy/boot /floppy/etc
151 cd $NFSROOT/boot
152 # do not copy System.map*
153 cp -dp map chain* boot* vmlinuz-$KERNELVERSION /floppy/boot 2>/dev/null || true
154 ln -s boot/vmlinuz-$KERNELVERSION /floppy/vmlinuz
155 # since lilo 21.5, boot.b is a link
156 [ -e /floppy/boot/boot.b ] || ln -fs /floppy/boot/boot-compat.b /floppy/boot/boot.b
157
158 [ $MKIMAGE -eq 1 ] && cat > /floppy/etc/lilo.conf << EOF
159 disk=/dev/loop0
160 bios=0x00
161 cylinders=80
162 heads=2
163 sectors=18
164 EOF
165
166 cat >> /floppy/etc/lilo.conf <<-EOF
167 boot=$floppydev
168 root=$NFSROOT/dev/boot255
169 install=/floppy/boot/boot.b
170 map=/floppy/boot/map
171 append="nfsroot=$SERVERIP:$NFSROOT $params"
172 delay=10
173 compact
174 image=/floppy/vmlinuz
175 label=FAI-$TYPE
176 read-only
177 EOF
178
179 $NFSROOT/sbin/lilo -C /floppy/etc/lilo.conf
180
181 cat <<EOF
182 Writing boot data to floppy.
183 boot protocol : $TYPE
184 nfsroot : $SERVERIP:$NFSROOT
185 parameters : $params
186 The kernel configuration is $NFSROOT/boot/config-$KERNELVERSION-$TYPE.
187 EOF

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5