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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5