mirror of
https://github.com/ipxe/ipxe
synced 2025-12-08 02:10:25 +03:00
Initial revision
This commit is contained in:
46
contrib/initrd/ChangeLog
Normal file
46
contrib/initrd/ChangeLog
Normal file
@@ -0,0 +1,46 @@
|
||||
mkinitrd-net ChangeLog
|
||||
|
||||
Last Modified: Fri Jul 26 23:08:28 2002
|
||||
|
||||
$Log$
|
||||
Revision 1.1 2005/05/17 16:45:02 mcb30
|
||||
Initial revision
|
||||
|
||||
Revision 1.1 2002/11/06 06:31:06 ken_yap
|
||||
Contributed by Michael Brown.
|
||||
|
||||
Revision 1.10 2002/07/26 23:09:13 mcb30
|
||||
Support for new binary etherboot.nic-dev-id structure
|
||||
Added --kernel option patch from Stew Benedict at MandrakeSoft
|
||||
Only try to use sudo if we are not already root
|
||||
|
||||
Revision 1.9 2002/06/05 13:31:50 mcb30
|
||||
Modifications to allow DHCP, TFTP and NFS servers to be separate machines.
|
||||
|
||||
Revision 1.8 2002/05/30 11:41:18 mcb30
|
||||
/tftpboot symlinked to /var/lib/tftpboot
|
||||
Has ability to be quiet if "quiet" specified on kernel cmdline
|
||||
|
||||
Revision 1.7 2002/05/26 11:15:04 mcb30
|
||||
PCI-ID auto-mapping via dhcpd.conf.etherboot-pcimap.include
|
||||
|
||||
Revision 1.6 2002/05/24 02:05:11 mcb30
|
||||
Bugfixes, migrated /tftpboot to /var/lib/tftpboot
|
||||
|
||||
Revision 1.5 2002/05/23 21:29:58 mcb30
|
||||
Now includes dhcpd.conf.etherboot.include
|
||||
Automatically scans for all network modules in the pcimap file
|
||||
|
||||
Revision 1.4 2002/05/08 09:04:31 mcb30
|
||||
Bugfixes: tmpdir selection, linuxrc typos, ifconfig peculiarities
|
||||
|
||||
Revision 1.3 2002/05/04 21:44:13 mcb30
|
||||
During %make, LIBDIR must be set for mknbi
|
||||
Added %post scriptlet since %trigger seems not to be being triggered...
|
||||
|
||||
Revision 1.2 2002/05/04 21:20:32 mcb30
|
||||
Added extra sources instead of requiring "make" to download them
|
||||
|
||||
Revision 1.1 2002/05/04 13:19:40 mcb30
|
||||
First attempt at an RPM package
|
||||
|
||||
187
contrib/initrd/Makefile
Normal file
187
contrib/initrd/Makefile
Normal file
@@ -0,0 +1,187 @@
|
||||
UCLIBC_VERSION = 0.9.11
|
||||
UCLIBC = uClibc-$(UCLIBC_VERSION)
|
||||
$(UCLIBC)_SOURCE = http://www.uclibc.org/downloads/$(UCLIBC).tar.bz2
|
||||
UCLIBC_INSTALL = $(CURDIR)/uClibc
|
||||
|
||||
UDHCP_VERSION = 0.9.7
|
||||
UDHCP = udhcp-$(UDHCP_VERSION)
|
||||
$(UDHCP)_SOURCE = http://udhcp.busybox.net/source/$(UDHCP).tar.gz
|
||||
|
||||
BUSYBOX_VERSION = 0.60.3
|
||||
BUSYBOX = busybox-$(BUSYBOX_VERSION)
|
||||
$(BUSYBOX)_SOURCE = http://www.busybox.net/downloads/$(BUSYBOX).tar.bz2
|
||||
|
||||
LINUX_WLAN_VERSION = 0.1.13
|
||||
LINUX_WLAN = linux-wlan-ng-$(LINUX_WLAN_VERSION)
|
||||
$(LINUX_WLAN)_SOURCE = ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/$(LINUX_WLAN).tar.gz
|
||||
|
||||
MKNBI_VERSION = 1.2
|
||||
MKNBI = mknbi-$(MKNBI_VERSION)
|
||||
$(MKNBI)_SOURCE = http://belnet.dl.sourceforge.net/sourceforge/etherboot/$(MKNBI).tar.gz
|
||||
|
||||
export PATH := $(UCLIBC_INSTALL)/bin:$(PATH)
|
||||
|
||||
all : utils initrd-skel mknbi mknbi-linux
|
||||
# Run "make tftpboot/initrd-kernel_module.img" to generate a suitable initrd
|
||||
# Run "make tftpboot/boot-kernel_module.nbi" to generate a suitable NBI
|
||||
# Run "make all-nbi" to generate a complete set of NBIs
|
||||
|
||||
%.tar.bz2 :
|
||||
[ -d $* ] || wget $($*_SOURCE)
|
||||
[ -f $*.t*gz ] && ( gunzip $*.t*gz ; bzip2 -9 $*.tar ) || true
|
||||
|
||||
UTILS = udhcpc busybox wlanctl
|
||||
|
||||
utils : $(UTILS)
|
||||
|
||||
clean : partlyclean
|
||||
rm -rf uClibc
|
||||
rm -rf $(UCLIBC)
|
||||
rm -rf tftpboot/*
|
||||
|
||||
partlyclean :
|
||||
rm -rf $(UDHCP)
|
||||
rm -rf $(BUSYBOX)
|
||||
rm -rf $(LINUX_WLAN)
|
||||
rm -rf $(MKNBI)
|
||||
rm -rf initrd-skel
|
||||
rm -f *.img *.ird *.nbi insert-modules
|
||||
rm -f $(UTILS) mknbi-linux
|
||||
rm -f *.uClibc *.busybox *.udhcpc *.wlanctl
|
||||
|
||||
.PHONY : all utils clean partlyclean
|
||||
|
||||
uClibc : $(UCLIBC)
|
||||
rm -rf $@
|
||||
$(MAKE) -C $(UCLIBC) install
|
||||
|
||||
$(UCLIBC) : $(UCLIBC).tar.bz2
|
||||
[ -d $@ ] || tar xvjf $<
|
||||
[ -f $(UCLIBC)/Config ] || perl -pe 's/^(INCLUDE_RPC).*/$$1 = true/ ;' \
|
||||
-e 's{^(DEVEL_PREFIX).*}{$$1 = $(UCLIBC_INSTALL)} ;' \
|
||||
-e 's{^(SHARED_LIB_LOADER_PATH).*}{$$1 = /lib} ;' \
|
||||
$(UCLIBC)/extra/Configs/Config.i386 > $(UCLIBC)/Config
|
||||
# Stripping out spurious CVS directories (screws up local cvs update)
|
||||
rm -rf `find $(UCLIBC) -name CVS`
|
||||
$(MAKE) -C $(UCLIBC)
|
||||
install -m 644 $(UCLIBC)/COPYING.LIB COPYING.uClibc
|
||||
|
||||
udhcpc : $(UDHCP)
|
||||
install -m 755 -s $(UDHCP)/$@ $@
|
||||
|
||||
$(UDHCP) : $(UDHCP).tar.bz2 uClibc
|
||||
[ -d $@ ] || tar xvjf $<
|
||||
if [ ! -f $@/.script.c.patch ]; then \
|
||||
patch -d $@ -b -z .orig < script.c.patch ; \
|
||||
touch $@/.script.c.patch ; \
|
||||
fi
|
||||
$(MAKE) LDFLAGS+=-static -C $(UDHCP)
|
||||
install -m 644 $(UDHCP)/AUTHORS AUTHORS.udhcpc
|
||||
install -m 644 $(UDHCP)/COPYING COPYING.udhcpc
|
||||
|
||||
busybox : $(BUSYBOX)
|
||||
install -m 755 -s $(BUSYBOX)/$@ $@
|
||||
|
||||
$(BUSYBOX) : $(BUSYBOX).tar.bz2 uClibc
|
||||
[ -d $@ ] || tar xvjf $<
|
||||
perl -pi.orig -e \
|
||||
's/^.*(#define BB_(FEATURE_NFSMOUNT|INSMOD|PIVOT_ROOT|IFCONFIG|ROUTE)).*/$$1/' \
|
||||
$(BUSYBOX)/Config.h
|
||||
perl -pi.orig -e \
|
||||
's/^(DOSTATIC).*$$/$$1 = true/' \
|
||||
$(BUSYBOX)/Makefile
|
||||
$(MAKE) -C $(BUSYBOX)
|
||||
install -m 644 $(BUSYBOX)/AUTHORS AUTHORS.busybox
|
||||
install -m 644 $(BUSYBOX)/LICENSE LICENSE.busybox
|
||||
|
||||
wlanctl : $(LINUX_WLAN)
|
||||
install -m 755 -s $(LINUX_WLAN)/src/wlanctl/$@ $@
|
||||
|
||||
$(LINUX_WLAN) : $(LINUX_WLAN).tar.bz2 uClibc linux-wlan.cfg
|
||||
[ -d $@ ] || tar xvjf $<
|
||||
cd $(LINUX_WLAN) ; ./Configure -d ../linux-wlan.cfg
|
||||
perl -pi.orig -e \
|
||||
's/(-o wlanctl)/-static $$1/' \
|
||||
$(LINUX_WLAN)/src/wlanctl/Makefile
|
||||
$(MAKE) -C $(LINUX_WLAN)/src/wlanctl
|
||||
install -m 644 $(LINUX_WLAN)/COPYING COPYING.wlanctl
|
||||
install -m 644 $(LINUX_WLAN)/LICENSE LICENSE.wlanctl
|
||||
install -m 644 $(LINUX_WLAN)/THANKS THANKS.wlanctl
|
||||
|
||||
mknbi-linux : $(MKNBI)
|
||||
|
||||
mknbi : $(MKNBI)
|
||||
|
||||
$(MKNBI) : $(MKNBI).tar.bz2
|
||||
[ -d $@ ] || tar xvjf $<
|
||||
if [ ! -f $@/.mknbi-encap.patch ]; then \
|
||||
patch -d $@ -b -z .orig < mknbi-encap.patch ; \
|
||||
touch $@/.mknbi-encap.patch ; \
|
||||
fi
|
||||
make -C $(MKNBI) LIBDIR=`pwd`/$(MKNBI) mknbi
|
||||
install -m 755 $(MKNBI)/mknbi mknbi-linux
|
||||
make -C $(MKNBI) clean
|
||||
make -C $(MKNBI)
|
||||
|
||||
initrd-skel : $(UTILS) linuxrc udhcpc-post include-modules
|
||||
rm -rf $@
|
||||
mkdir -p $@
|
||||
mkdir -p $@/dev
|
||||
mkdir -p $@/etc
|
||||
mkdir -p $@/bin
|
||||
mkdir -p $@/lib
|
||||
mkdir -p $@/lib/modules
|
||||
mkdir -p $@/proc
|
||||
mkdir -p $@/sysroot
|
||||
ln -s bin $@/sbin
|
||||
install -m 755 busybox $@/bin/
|
||||
install -m 755 udhcpc $@/bin/
|
||||
install -m 755 wlanctl $@/bin/
|
||||
ln -s busybox $@/bin/sh
|
||||
ln -s busybox $@/bin/echo
|
||||
ln -s busybox $@/bin/mknod
|
||||
ln -s busybox $@/bin/chmod
|
||||
ln -s busybox $@/bin/insmod
|
||||
ln -s busybox $@/bin/ifconfig
|
||||
ln -s busybox $@/bin/route
|
||||
ln -s busybox $@/bin/mount
|
||||
ln -s busybox $@/bin/pivot_root
|
||||
ln -s busybox $@/bin/umount
|
||||
ln -s busybox $@/bin/[
|
||||
ln -s busybox $@/bin/sleep
|
||||
ln -s busybox $@/bin/grep
|
||||
|
||||
install -m 755 linuxrc $@/linuxrc
|
||||
install -m 755 udhcpc-post $@/bin/udhcpc-post
|
||||
|
||||
tftpboot/initrd-%.img : initrd-skel
|
||||
./mkinitrd-net -l `echo $* | tr . " "`
|
||||
|
||||
tftpboot/boot-%.nbi : tftpboot/initrd-%.img mknbi-linux
|
||||
./mknbi-linux --format=nbi --target=linux /boot/vmlinuz $< > $@
|
||||
sudo cp $@ $(tftpbootdir)
|
||||
|
||||
all-nbi : all
|
||||
./mknbi-set -l -v
|
||||
ls tftpboot
|
||||
|
||||
prefix = /usr
|
||||
sysconfdir = /etc
|
||||
bindir = $(prefix)/bin
|
||||
libdir = $(prefix)/lib
|
||||
mandir = $(prefix)/share/man
|
||||
docdir = $(prefix)/share/doc
|
||||
tftpbootdir = /var/lib/tftpboot
|
||||
initrdskeldir = $(prefix)/lib/mkinitrd-net/initrd-skel
|
||||
|
||||
install :
|
||||
mkdir -p $(libdir)/mknbi
|
||||
mkdir -p $(bindir)
|
||||
mkdir -p $(sysconfdir)
|
||||
mkdir -p $(tftpbootdir)
|
||||
mkdir -p $(initrdskeldir)
|
||||
install -m 755 mkinitrd-net include-modules mknbi-set $(bindir)/
|
||||
cp -a initrd-skel/* $(initrdskeldir)/
|
||||
install -m 644 mknbi-set.conf dhcpd.conf.etherboot.include $(sysconfdir)
|
||||
make -C $(MKNBI) INSTPREFIX=$(prefix) MANDIR=$(mandir)/man1 \
|
||||
DOCDIR=$(docdir)/$(MKNBI) install
|
||||
15
contrib/initrd/Manifest
Normal file
15
contrib/initrd/Manifest
Normal file
@@ -0,0 +1,15 @@
|
||||
initrd/ChangeLog
|
||||
initrd/Makefile
|
||||
initrd/Manifest
|
||||
initrd/README
|
||||
initrd/dhcpd.conf.etherboot.include
|
||||
initrd/include-modules
|
||||
initrd/linux-wlan.cfg
|
||||
initrd/linuxrc
|
||||
initrd/mkinitrd-net
|
||||
initrd/mkinitrd-net.spec
|
||||
initrd/mknbi-encap.patch
|
||||
initrd/mknbi-set
|
||||
initrd/mknbi-set.conf
|
||||
initrd/script.c.patch
|
||||
initrd/udhcpc-post
|
||||
37
contrib/initrd/README
Normal file
37
contrib/initrd/README
Normal file
@@ -0,0 +1,37 @@
|
||||
README for mkinitrd-net
|
||||
|
||||
mkinitrd-net enables you to use your distribution's stock kernel for
|
||||
diskless workstations, without having to compile in support for the
|
||||
relevant network card(s). It creates an initial ramdisk image containing
|
||||
the required network-card kernel modules and bootstrap scripts to load the
|
||||
module, obtain an IP address via DHCP and mount the root filesystem via
|
||||
NFS.
|
||||
|
||||
mkinitrd-net also generates a dhcpd.conf file fragment that can be used to
|
||||
automate the process of mapping NBI files to clients, based on the PCI IDs
|
||||
of their network cards. Etherboot will send the PCI ID of the network
|
||||
card to the DHCP server in the etherboot-encapsulated-options field
|
||||
(Etherboot 5.0.7 and newer) and the DHCP server can use this to identify
|
||||
the correct NBI to point the client towards.
|
||||
|
||||
The end result is that:
|
||||
|
||||
a) You can avoid the hassle of compiling custom kernels for diskless
|
||||
workstations.
|
||||
|
||||
b) Diskless workstations will automatically download the correct
|
||||
kernel+initrd.
|
||||
|
||||
c) You have an easier life! :-)
|
||||
|
||||
|
||||
|
||||
mkinitrd-net is Copyright Fen Systems Ltd. 2001. mkinitrd-net itself is
|
||||
licensed under the GNU GPL. It incorporates code from the uClibc,
|
||||
busybox, udhcpc and Etherboot projects, each of which has its own licence
|
||||
terms. Standard disclaimers apply.
|
||||
|
||||
The copy of mkinitrd-net in the Etherboot contribs is not the
|
||||
authoritative copy of mkinitrd-net; please do not make modifications to
|
||||
this copy. Patches should be sent to Michael Brown
|
||||
<mbrown@fensystems.co.uk>.
|
||||
207
contrib/initrd/dhcpd.conf.etherboot.include
Normal file
207
contrib/initrd/dhcpd.conf.etherboot.include
Normal file
@@ -0,0 +1,207 @@
|
||||
# dhcpd.conf include file for Etherboot
|
||||
#
|
||||
# Include this file from your /etc/dhcpd.conf
|
||||
# $Id$
|
||||
|
||||
# Definition of Etherboot options
|
||||
# (taken from vendortags.html)
|
||||
|
||||
# We use an encapsulated option space to avoid polluting the site-local DHCP option space
|
||||
#
|
||||
option space etherboot;
|
||||
option etherboot-encapsulated-options code 150 = encapsulate etherboot;
|
||||
|
||||
# Definition of option codes within the etherboot-encapsulated-options space
|
||||
#
|
||||
option etherboot.extensions-path code 18 = string;
|
||||
option etherboot.magic code 128 = string;
|
||||
option etherboot.kernel-cmdline code 129 = string;
|
||||
option etherboot.menu-opts code 160 = string;
|
||||
option etherboot.nic-dev-id code 175 = string;
|
||||
option etherboot.menu-selection code 176 = unsigned integer 8;
|
||||
option etherboot.motd-1 code 184 = string;
|
||||
option etherboot.motd-2 code 185 = string;
|
||||
option etherboot.motd-3 code 186 = string;
|
||||
option etherboot.motd-4 code 187 = string;
|
||||
option etherboot.motd-5 code 188 = string;
|
||||
option etherboot.motd-6 code 189 = string;
|
||||
option etherboot.motd-7 code 190 = string;
|
||||
option etherboot.motd-8 code 191 = string;
|
||||
option etherboot.image-1 code 192 = string;
|
||||
option etherboot.image-2 code 193 = string;
|
||||
option etherboot.image-3 code 194 = string;
|
||||
option etherboot.image-4 code 195 = string;
|
||||
option etherboot.image-5 code 196 = string;
|
||||
option etherboot.image-6 code 197 = string;
|
||||
option etherboot.image-7 code 198 = string;
|
||||
option etherboot.image-8 code 199 = string;
|
||||
option etherboot.image-9 code 200 = string;
|
||||
option etherboot.image-10 code 201 = string;
|
||||
option etherboot.image-11 code 202 = string;
|
||||
option etherboot.image-12 code 203 = string;
|
||||
option etherboot.image-13 code 204 = string;
|
||||
option etherboot.image-14 code 205 = string;
|
||||
option etherboot.image-15 code 206 = string;
|
||||
option etherboot.image-16 code 207 = string;
|
||||
option etherboot.kmod code 254 = string;
|
||||
|
||||
# Legacy support for Etherboot options as site-local options (i.e. non-encapsulated)
|
||||
# Note: options defined after the switch to encapsulated options should not be defined here
|
||||
#
|
||||
option legacy-etherboot-magic code 128 = string;
|
||||
option legacy-etherboot-kernel-cmdline code 129 = string;
|
||||
option legacy-etherboot-menu-opts code 160 = string;
|
||||
option legacy-etherboot-menu-selection code 176 = unsigned integer 8;
|
||||
option legacy-etherboot-motd-1 code 184 = string;
|
||||
option legacy-etherboot-motd-2 code 185 = string;
|
||||
option legacy-etherboot-motd-3 code 186 = string;
|
||||
option legacy-etherboot-motd-4 code 187 = string;
|
||||
option legacy-etherboot-motd-5 code 188 = string;
|
||||
option legacy-etherboot-motd-6 code 189 = string;
|
||||
option legacy-etherboot-motd-7 code 190 = string;
|
||||
option legacy-etherboot-motd-8 code 191 = string;
|
||||
option legacy-etherboot-image-1 code 192 = string;
|
||||
option legacy-etherboot-image-2 code 193 = string;
|
||||
option legacy-etherboot-image-3 code 194 = string;
|
||||
option legacy-etherboot-image-4 code 195 = string;
|
||||
option legacy-etherboot-image-5 code 196 = string;
|
||||
option legacy-etherboot-image-6 code 197 = string;
|
||||
option legacy-etherboot-image-7 code 198 = string;
|
||||
option legacy-etherboot-image-8 code 199 = string;
|
||||
option legacy-etherboot-image-9 code 200 = string;
|
||||
option legacy-etherboot-image-10 code 201 = string;
|
||||
option legacy-etherboot-image-11 code 202 = string;
|
||||
option legacy-etherboot-image-12 code 203 = string;
|
||||
option legacy-etherboot-image-13 code 204 = string;
|
||||
option legacy-etherboot-image-14 code 205 = string;
|
||||
option legacy-etherboot-image-15 code 206 = string;
|
||||
option legacy-etherboot-image-16 code 207 = string;
|
||||
|
||||
# Apply Etherboot options only for Etherboot clients
|
||||
#
|
||||
if substring ( option vendor-class-identifier, 0, 9 ) = "Etherboot" {
|
||||
|
||||
# We must specify this value for etherboot-magic, or Etherboot will
|
||||
# ignore all other options.
|
||||
#
|
||||
option etherboot.magic E4:45:74:68:00:00;
|
||||
|
||||
# Bootfile name: derive from etherboot.kmod (calculated below)
|
||||
# Use boot.nbi if no NIC_DEV_ID option present
|
||||
# (i.e. if etherboot.kmod doesn't get set)
|
||||
# Also pass filename back in filename field
|
||||
#
|
||||
option bootfile-name = pick-first-value ( concat ( "boot-",
|
||||
config-option etherboot.kmod,
|
||||
".nbi" ),
|
||||
"boot.nbi" ) ;
|
||||
filename = config-option bootfile-name;
|
||||
|
||||
# "Sensible" default values for some options
|
||||
|
||||
# Mount devfs (will probably be needed for a network-boot)
|
||||
option etherboot.kernel-cmdline " devfs=mount";
|
||||
|
||||
# Info message (includes client IP address, MAC address, hardware ID string,
|
||||
# server IP address and name of boot file)
|
||||
option etherboot.motd-4 = concat ( "Using Etherboot to boot ",
|
||||
binary-to-ascii ( 10, 8, ".", leased-address ),
|
||||
" [",
|
||||
binary-to-ascii ( 16, 8, ":", suffix ( hardware, 6 ) ),
|
||||
"] [",
|
||||
pick-first-value ( option etherboot.nic-dev-id, "unknown card" ),
|
||||
"]", 0d:0a, " from ",
|
||||
binary-to-ascii ( 10, 8, ".", option dhcp-server-identifier ),
|
||||
" with file ",
|
||||
config-option tftp-server-name,
|
||||
":",
|
||||
config-option bootfile-name,
|
||||
" [",
|
||||
pick-first-value ( config-option etherboot.kmod, "unknown module" ),
|
||||
"]", 0d:0a );
|
||||
|
||||
# Legacy site-local option support
|
||||
# If client does not include an etherboot-encapsulated-options field in its DHCPREQUEST, then
|
||||
# it will not understand etherboot-encapsulated-options in the DHCPACK and so we must send
|
||||
# back the options as site-local options (i.e. not encapsulated).
|
||||
# Note: we need do this only for options that existed prior to the switch to encapsulation.
|
||||
#
|
||||
if not exists etherboot-encapsulated-options {
|
||||
option legacy-etherboot-magic = config-option etherboot.magic;
|
||||
option legacy-etherboot-kernel-cmdline = config-option etherboot.kernel-cmdline;
|
||||
option legacy-etherboot-menu-opts = config-option etherboot.menu-opts;
|
||||
option legacy-etherboot-menu-selection = config-option etherboot.menu-selection;
|
||||
option legacy-etherboot-motd-1 = config-option etherboot.motd-1;
|
||||
option legacy-etherboot-motd-2 = config-option etherboot.motd-2;
|
||||
option legacy-etherboot-motd-3 = config-option etherboot.motd-3;
|
||||
option legacy-etherboot-motd-4 = config-option etherboot.motd-4;
|
||||
option legacy-etherboot-motd-5 = config-option etherboot.motd-5;
|
||||
option legacy-etherboot-motd-6 = config-option etherboot.motd-6;
|
||||
option legacy-etherboot-motd-7 = config-option etherboot.motd-7;
|
||||
option legacy-etherboot-motd-8 = config-option etherboot.motd-8;
|
||||
option legacy-etherboot-image-1 = config-option etherboot.image-1;
|
||||
option legacy-etherboot-image-2 = config-option etherboot.image-2;
|
||||
option legacy-etherboot-image-3 = config-option etherboot.image-3;
|
||||
option legacy-etherboot-image-4 = config-option etherboot.image-4;
|
||||
option legacy-etherboot-image-5 = config-option etherboot.image-5;
|
||||
option legacy-etherboot-image-6 = config-option etherboot.image-6;
|
||||
option legacy-etherboot-image-7 = config-option etherboot.image-7;
|
||||
option legacy-etherboot-image-8 = config-option etherboot.image-8;
|
||||
option legacy-etherboot-image-9 = config-option etherboot.image-9;
|
||||
option legacy-etherboot-image-10 = config-option etherboot.image-10;
|
||||
option legacy-etherboot-image-11 = config-option etherboot.image-11;
|
||||
option legacy-etherboot-image-12 = config-option etherboot.image-12;
|
||||
option legacy-etherboot-image-13 = config-option etherboot.image-13;
|
||||
option legacy-etherboot-image-14 = config-option etherboot.image-14;
|
||||
option legacy-etherboot-image-15 = config-option etherboot.image-15;
|
||||
option legacy-etherboot-image-16 = config-option etherboot.image-16;
|
||||
}
|
||||
}
|
||||
|
||||
# Some options should be set for both Etherboot and the udhcpc client
|
||||
#
|
||||
if ( ( substring ( option vendor-class-identifier, 0, 9 ) = "Etherboot" )
|
||||
or ( substring ( option vendor-class-identifier, 0, 5 ) = "udhcp" ) ) {
|
||||
|
||||
# TFTP server defaults to DHCP server and is specified in both
|
||||
# next-server field and tftp-server-name option field
|
||||
#
|
||||
option tftp-server-name = binary-to-ascii ( 10, 8, ".", config-option dhcp-server-identifier );
|
||||
server-name = config-option tftp-server-name;
|
||||
next-server = config-option dhcp-server-identifier;
|
||||
|
||||
# Root path defaults to root of TFTP server
|
||||
option root-path = concat ( config-option tftp-server-name, ":/" );
|
||||
|
||||
# A fallback hostname, generated from the IP address
|
||||
option host-name = concat ( "client_", binary-to-ascii ( 10, 8, "_", leased-address ) );
|
||||
}
|
||||
|
||||
# Force some items onto parameter request list for udhcp
|
||||
#
|
||||
if substring ( option vendor-class-identifier, 0, 5 ) = "udhcp" {
|
||||
# Forcibly add root-path to list
|
||||
option dhcp-parameter-request-list = concat ( option dhcp-parameter-request-list, 11 );
|
||||
}
|
||||
|
||||
# Etherboot sends a string to identify the NIC in etherboot.nic-dev-id.
|
||||
# For PCI NICs, this string is of the form "PCI:vvvv:dddd" where vvvv is the
|
||||
# vendor identifier and dddd the device identifier, in lower-case ASCII hex.
|
||||
# For ISA NICs, the format of the string is "ISA:..." where ... is not yet
|
||||
# decided upon.
|
||||
#
|
||||
# We use the identifier to select the NBI image that will be specified via
|
||||
# the "bootfile-name" option.
|
||||
#
|
||||
# PCI NICs - use PCI vendor and device IDs
|
||||
# Listed in file generated by mknbi-set
|
||||
#
|
||||
include "/etc/dhcpd.conf.etherboot-pcimap.include";
|
||||
|
||||
# ISA NICs
|
||||
#
|
||||
if substring ( option vendor-class-identifier, 0, 9 ) = "Etherboot" {
|
||||
if exists etherboot.nic-dev-id {
|
||||
|
||||
}
|
||||
}
|
||||
63
contrib/initrd/include-modules
Executable file
63
contrib/initrd/include-modules
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Retrieve modules required for an initrd image
|
||||
# $Id$
|
||||
|
||||
unless ( @ARGV ) {
|
||||
die "Syntax: $0 [ -d target_directory ] module_1 module_2 module_3\n"
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
my @requested_modules = ();
|
||||
my $target_dir = "";
|
||||
my $kernel_ver;
|
||||
my $quiet;
|
||||
chomp ( my $current_kernel_ver = `uname -r` );
|
||||
while ( $_ = shift ) {
|
||||
if ( /-d/ ) { $target_dir = shift }
|
||||
elsif ( /-k/ ) { $kernel_ver = shift }
|
||||
elsif ( /-q/ ) { $quiet = 1 }
|
||||
else { push @requested_modules, $_ };
|
||||
}
|
||||
|
||||
# Create target directory if required
|
||||
if ( $target_dir ) {
|
||||
print STDERR "Target directory is $target_dir\n" unless $quiet;
|
||||
system ( "mkdir -p $target_dir" );
|
||||
chdir $target_dir;
|
||||
}
|
||||
|
||||
# Use modprobe -nav to retrieve locations of modules and their dependencies
|
||||
print STDERR "Requested modules ". join (' ', @requested_modules)."\n" unless $quiet;
|
||||
my @modules_dups;
|
||||
foreach my $module ( @requested_modules ) {
|
||||
my @module_list = map { /^\S+\s+(.*)$/ ; $1 } `/sbin/modprobe -nva $module`;
|
||||
die "Cannot find any modules matching $module\n" unless @module_list;
|
||||
push @modules_dups, @module_list;
|
||||
}
|
||||
|
||||
# Remove duplicates from list
|
||||
my %module_basenames = ();
|
||||
my @modules = ();
|
||||
foreach my $module ( @modules_dups ) {
|
||||
# Ugly hack : assume that dependencies are independent of kernel version
|
||||
# This seems to be necessary because we can't run modprobe and specify
|
||||
# an alternate modules.dep file; it refuses to understand lines of the
|
||||
# form "depfile=XXX" as documented in modules.conf(5)
|
||||
$module =~ s/$current_kernel_ver/$kernel_ver/ if $kernel_ver;
|
||||
push @modules, $module unless $module_basenames{$module};
|
||||
( my $basename ) = ( $module =~ /([^\/]+)\.o/ );
|
||||
$module_basenames{$module} = $basename;
|
||||
}
|
||||
|
||||
# Process module list
|
||||
print "#!/bin/sh\n";
|
||||
foreach my $module ( @modules ) {
|
||||
my $basename = $module_basenames{$module};
|
||||
# Report via stdout
|
||||
print STDERR "Using module $basename from $module\n" unless $quiet;
|
||||
# Copy uncompressed module to current directory
|
||||
system ("gunzip -c $module > $basename.o");
|
||||
# Print insmod line to stdout
|
||||
print "insmod $basename\n";
|
||||
}
|
||||
7
contrib/initrd/linux-wlan.cfg
Normal file
7
contrib/initrd/linux-wlan.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
# Dummy config file for building only wlanctl
|
||||
# $Id$
|
||||
|
||||
PRISM2_PLX=n
|
||||
PRISM2_PCMCIA=n
|
||||
PRISM2_PCI=n
|
||||
PRISM2_USB=n
|
||||
76
contrib/initrd/linuxrc
Normal file
76
contrib/initrd/linuxrc
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
# $Id$
|
||||
|
||||
PATH=/sbin:/bin
|
||||
|
||||
echo Busybox /linuxrc starting
|
||||
|
||||
echo Mounting /proc filesystem
|
||||
mount -t proc none /proc
|
||||
|
||||
echo=echo
|
||||
if grep '\bquiet\b' /proc/cmdline > /dev/null; then
|
||||
echo=true
|
||||
quiet=1
|
||||
fi
|
||||
|
||||
$echo Creating root device
|
||||
mknod /dev/root b 1 0 2>/dev/null
|
||||
chmod 700 /dev/root
|
||||
echo 0x100 > /proc/sys/kernel/real-root-dev
|
||||
|
||||
$echo Inserting modules
|
||||
if [ -z "$quiet" ]; then
|
||||
/bin/insert-modules
|
||||
else
|
||||
/bin/insert-modules >/dev/null
|
||||
fi
|
||||
|
||||
$echo Bringing up loopback interface
|
||||
ifconfig lo 127.0.0.1 up
|
||||
route add -net 127.0.0.0 netmask 255.0.0.0 lo
|
||||
|
||||
# Hack required for prism2 cards
|
||||
# It is not yet possible to use iwconfig to configure these cards,
|
||||
# so we need wlanctl.
|
||||
if ifconfig wlan0 down 2> /dev/null; then
|
||||
$echo Setting up wireless link
|
||||
wlanctl wlan0 lnxreq_ifstate ifstate=enable
|
||||
wlanctl wlan0 lnxreq_autojoin ssid= authtype=opensystem
|
||||
fi
|
||||
|
||||
$echo Obtaining IP address via DHCP
|
||||
$echo Trying to obtain IP address via wired link [eth0]
|
||||
if udhcpc -i eth0 -f -n -q -s /bin/udhcpc-post; then
|
||||
$echo Successfully obtained IP address via wired link [eth0]
|
||||
else
|
||||
$echo Failed to obtain IP address via wired link [eth0]
|
||||
$echo Trying to obtain IP address via wireless link [wlan0]
|
||||
udhcpc -i wlan0 -f -n -q -s /bin/udhcpc-post
|
||||
fi
|
||||
|
||||
if [ -d /sysroot/initrd ]; then
|
||||
$echo Unmounting /proc prior to pivot_root
|
||||
umount /proc
|
||||
|
||||
$echo Pivoting root to /sysroot
|
||||
pivot_root /sysroot /sysroot/initrd
|
||||
cd /
|
||||
|
||||
$echo Remounting devfs at correct place
|
||||
mount -t devfs none /dev
|
||||
|
||||
$echo Releasing locks on old devfs
|
||||
exec 0</dev/null
|
||||
exec 1>/dev/console
|
||||
exec 2>/dev/console
|
||||
|
||||
$echo Unmounting old devfs
|
||||
umount /initrd/dev
|
||||
else
|
||||
# Failed to mount root: report error and hang
|
||||
echo FATAL ERROR: Failed to mount root filesystem
|
||||
echo Press Alt-SysRq-B or hit the reset switch to reboot
|
||||
while : ; do sleep 6000 ; done
|
||||
fi
|
||||
|
||||
165
contrib/initrd/mkinitrd-net
Executable file
165
contrib/initrd/mkinitrd-net
Executable file
@@ -0,0 +1,165 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id$
|
||||
# initrd builder for network booting
|
||||
|
||||
# Utility function to determine whether or not a filesystem is usable for
|
||||
# loopback mounts. Lifted verbatim from Erik Troan's mkinitrd script.
|
||||
#
|
||||
is_good_fs() {
|
||||
local parttype= tmpname=
|
||||
local dir=$1
|
||||
[[ -d $dir ]] || return 1
|
||||
[[ -w $dir ]] || return 1
|
||||
[[ $dir == */ ]] && dir=${dir%/}
|
||||
parttype=$(awk "{if (\$2 == \""$dir"\") print \$3 }" /proc/mounts)
|
||||
|
||||
while tmpname=${dir%/*} && [[ -z $parttype ]];do
|
||||
[[ -z $tmpname ]] && tmpname=/
|
||||
parttype=$(awk "{if (\$2 == \""$tmpname"\") print \$3 }" /proc/mounts)
|
||||
dir=$tmpname
|
||||
done
|
||||
|
||||
case $parttype in
|
||||
nfs|tmpfs) return 1;;
|
||||
*) return 0;
|
||||
esac
|
||||
}
|
||||
|
||||
# Find a suitable temporary directory (i.e. not tmpfs or nfs)
|
||||
if is_good_fs $TMPDIR; then
|
||||
tmpdir=$TMPDIR
|
||||
elif is_good_fs /tmp; then
|
||||
tmpdir=/tmp
|
||||
elif is_good_fs /var/tmp; then
|
||||
tmpdir=/var/tmp
|
||||
elif is_good_fs /root/tmp; then
|
||||
tmpdir=/root/tmp
|
||||
else
|
||||
echo "Cannot use a tmp directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Default settings (some can be overridden by command-line options)
|
||||
include_modules=include-modules
|
||||
initrd_skel=/usr/lib/mkinitrd-net/initrd-skel
|
||||
kernel_ver=`uname -r`
|
||||
use_sudo=y
|
||||
keep=n
|
||||
output_dir=/var/lib/tftpboot
|
||||
make_link=y
|
||||
quiet=
|
||||
|
||||
# No need to use sudo if we are root
|
||||
if [ $UID -eq 0 ]; then
|
||||
use_sudo=n
|
||||
fi
|
||||
|
||||
USAGE="Usage: $0 [-k|--kernel <kernel_ver>] [-n|--nolink] [-q|--quiet] [-l|--local] [--nosudo] [--keep] [--help] module_list ..."
|
||||
|
||||
# Parse command-line options
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-l|--local)
|
||||
shift
|
||||
use_local=y ;;
|
||||
-k|--kernel)
|
||||
shift
|
||||
kernel_ver=$1
|
||||
shift ;;
|
||||
--nosudo) shift ; use_sudo=n ;;
|
||||
--keep) shift ; keep=y ;;
|
||||
--n|--nolink)
|
||||
shift ; make_link=n ;;
|
||||
-q|--quiet) shift ; quiet=-q ;;
|
||||
--help) shift ; do_help=y ;;
|
||||
--) shift ; break ;;
|
||||
-*) echo "${0}: ${1}: invalid option" >&2
|
||||
echo $USAGE >& 2
|
||||
exit 2 ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Build list of requested modules
|
||||
modules="$*"
|
||||
requested_modules="$modules"
|
||||
modules="$modules nfs" # Always require nfs for nfs mount
|
||||
modules="$modules af_packet" # Always require af_packet for udhcpc
|
||||
|
||||
# --help => Print help message
|
||||
if [ "$do_help" == "y" ]; then
|
||||
echo $USAGE
|
||||
echo " -k, --kernel Specify kernel version"
|
||||
echo " -n, --nolink Do not create a matching symbolic link"
|
||||
echo " -l, --local Run locally from CVS (for developers only)"
|
||||
echo " --nosudo Do not use sudo (i.e. must run as root instead)"
|
||||
echo " --keep Keep temporary files instead of deleting them"
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# --local => we are running directly from CVS, rather than
|
||||
# from an installed copy, so use local files and directories
|
||||
if [ "$use_local" == "y" ]; then
|
||||
include_modules=./include-modules
|
||||
initrd_skel=initrd-skel
|
||||
output_dir=tftpboot
|
||||
fi
|
||||
|
||||
# If use_sudo is set, check that sudo exists
|
||||
sudo=/usr/bin/sudo
|
||||
if [ "$use_sudo" == "y" ]; then
|
||||
if [ ! -x $sudo ]; then
|
||||
use_sudo=n
|
||||
echo "WARNING: --nosudo not specified but $sudo not found"
|
||||
fi
|
||||
fi
|
||||
if [ "$use_sudo" == "n" ]; then
|
||||
sudo=
|
||||
fi
|
||||
|
||||
# Create temporary working files
|
||||
initrd=`mktemp -d ${tmpdir}/initrd.XXXXXX`
|
||||
initrdimg=`mktemp ${tmpdir}/initrd.img.XXXXXX`
|
||||
initrdmnt=`mktemp -d ${tmpdir}/initrd.mnt.XXXXXX`
|
||||
|
||||
# Copy skeleton into temporary area
|
||||
cp -a $initrd_skel/* $initrd/
|
||||
mkdir -p $initrd/lib/modules/$kernel_ver
|
||||
$include_modules $quiet -k $kernel_ver -d $initrd/lib/modules/$kernel_ver $modules > $initrd/bin/insert-modules || exit 1
|
||||
chmod 755 $initrd/bin/insert-modules
|
||||
|
||||
# Create empty ext2fs image file
|
||||
dd if=/dev/zero bs=1k of=$initrdimg count=$((`du -sk $initrd | cut -f1` * 7 / 6)) 2> /dev/null
|
||||
/sbin/mke2fs -q -F $initrdimg 2> /dev/null
|
||||
|
||||
# Mount image file, copy files on, create /dev entries, display free space, umount
|
||||
$sudo mount -o loop $initrdimg $initrdmnt
|
||||
cp -a $initrd/* $initrdmnt/
|
||||
$sudo mknod $initrdmnt/dev/console c 5 1
|
||||
$sudo mknod $initrdmnt/dev/null c 1 3
|
||||
$sudo mknod $initrdmnt/dev/ram b 1 1
|
||||
$sudo mknod $initrdmnt/dev/systty c 4 0
|
||||
for i in 1 2 3 4; do $sudo mknod $initrdmnt/dev/tty$i c 4 $i; done
|
||||
if [ "$quiet" == "n" ]; then
|
||||
df -h $initrdmnt
|
||||
fi
|
||||
$sudo umount $initrdmnt
|
||||
|
||||
# Create output file
|
||||
initrd_suffix=`echo $requested_modules | tr " " .`
|
||||
gzip -9 -n -c $initrdimg > $output_dir/initrd-$initrd_suffix.$kernel_ver.img
|
||||
|
||||
# Create symlink
|
||||
if [ "$make_link" == "y" ]; then
|
||||
link=$output_dir/initrd-$initrd_suffix.img
|
||||
[ -L $link ] && rm -f $link
|
||||
ln -s initrd-$initrd_suffix.$kernel_ver.img $link
|
||||
fi
|
||||
|
||||
# Remove temporary files
|
||||
if [ "$keep" == "n" ]; then
|
||||
rm -rf $initrd
|
||||
rm -f $initrdimg
|
||||
rmdir $initrdmnt
|
||||
fi
|
||||
112
contrib/initrd/mkinitrd-net.spec
Normal file
112
contrib/initrd/mkinitrd-net.spec
Normal file
@@ -0,0 +1,112 @@
|
||||
%define name mkinitrd-net
|
||||
%define version 1.10
|
||||
%define release 1fs
|
||||
|
||||
Summary: Network-booting initrd builder
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
Source1: http://belnet.dl.sourceforge.net/sourceforge/etherboot/mknbi-1.2.tar.bz2
|
||||
Source2: http://www.busybox.net/downloads/busybox-0.60.3.tar.bz2
|
||||
Source3: http://www.uclibc.org/downloads/uClibc-0.9.11.tar.bz2
|
||||
Source4: ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/linux-wlan-ng-0.1.13.tar.bz2
|
||||
Source5: http://udhcp.busybox.net/source/udhcp-0.9.7.tar.bz2
|
||||
Copyright: GPL/LGPL/MPL
|
||||
Group: System/Kernel and hardware
|
||||
BuildRoot: %{_tmppath}/%{name}-buildroot
|
||||
Prefix: %{_prefix}
|
||||
Requires: tftp-server
|
||||
|
||||
%description
|
||||
mkinitrd-net allows you to build initial ramdisk images (initrds) suitable
|
||||
for use with Etherboot and other network-booting software. This package
|
||||
contains two main utilities: mkinitrd-net (to build an initrd containing a
|
||||
specified set of network-card modules) and mknbi (to generate
|
||||
Etherboot-usable NBI images from a given kernel and initrd). It also
|
||||
contains a helper script mknbi-set which will maintain sets of initrds to
|
||||
match all your currently-installed kernels.
|
||||
|
||||
mkinitrd-net uses code from the uClibc, busybox, udhcp and Etherboot
|
||||
projects.
|
||||
|
||||
%prep
|
||||
%setup -n initrd -a1 -a2 -a3 -a4 -a5
|
||||
|
||||
%build
|
||||
%make LIBDIR=%{_libdir}/mknbi
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%makeinstall tftpbootdir=$RPM_BUILD_ROOT%{_localstatedir}/tftpboot
|
||||
touch $RPM_BUILD_ROOT%{_sysconfdir}/dhcpd.conf.etherboot-pcimap.include
|
||||
ln -s %{_localstatedir}/tftpboot $RPM_BUILD_ROOT/tftpboot
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%post
|
||||
%{_bindir}/mknbi-set
|
||||
|
||||
%triggerin -- kernel kernel-smp kernel-secure kernel-enterprise
|
||||
%{_bindir}/mknbi-set
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%config(noreplace) %{_sysconfdir}/mknbi-set.conf
|
||||
%config(noreplace) %{_sysconfdir}/dhcpd.conf.etherboot.include
|
||||
%ghost %{_sysconfdir}/dhcpd.conf.etherboot-pcimap.include
|
||||
%{_bindir}/mknbi-*
|
||||
%{_bindir}/mkelf-*
|
||||
%{_bindir}/dis*
|
||||
%{_bindir}/mkinitrd-net
|
||||
%{_bindir}/include-modules
|
||||
%{_libdir}/mknbi
|
||||
%{_libdir}/mkinitrd-net
|
||||
%{_mandir}/man*/*
|
||||
/tftpboot
|
||||
%{_localstatedir}/tftpboot
|
||||
%doc README
|
||||
%doc AUTHORS.busybox LICENSE.busybox
|
||||
%doc AUTHORS.udhcpc COPYING.udhcpc
|
||||
%doc COPYING.wlanctl LICENSE.wlanctl THANKS.wlanctl
|
||||
%doc COPYING.uClibc
|
||||
%docdir %{_docdir}/mknbi*
|
||||
%{_docdir}/mknbi*
|
||||
|
||||
%changelog
|
||||
* Fri Jul 26 2002 Michael Brown <mbrown@fensystems.co.uk> 1.10-1fs
|
||||
- Support for new binary etherboot.nic-dev-id structure
|
||||
- Added --kernel option patch from Stew Benedict at MandrakeSoft
|
||||
- Only try to use sudo if we are not already root
|
||||
|
||||
* Wed Jun 05 2002 Michael Brown <mbrown@fensystems.co.uk> 1.9-1fs
|
||||
- Modifications to allow DHCP, TFTP and NFS servers to be separate machines.
|
||||
|
||||
* Thu May 30 2002 Michael Brown <mbrown@fensystems.co.uk> 1.8-1fs
|
||||
- /tftpboot symlinked to /var/lib/tftpboot
|
||||
- Has ability to be quiet if "quiet" specified on kernel cmdline
|
||||
|
||||
* Sun May 26 2002 Michael Brown <mbrown@fensystems.co.uk> 1.7-1fs
|
||||
- PCI-ID auto-mapping via dhcpd.conf.etherboot-pcimap.include
|
||||
|
||||
* Fri May 24 2002 Michael Brown <mbrown@fensystems.co.uk> 1.6-1fs
|
||||
- Bugfixes, migrated /tftpboot to /var/lib/tftpboot
|
||||
|
||||
* Thu May 23 2002 Michael Brown <mbrown@fensystems.co.uk> 1.5-1fs
|
||||
- Now includes dhcpd.conf.etherboot.include
|
||||
- Automatically scans for all network modules in the pcimap file
|
||||
|
||||
* Wed May 08 2002 Michael Brown <mbrown@fensystems.co.uk> 1.4-1fs
|
||||
- Bugfixes: tmpdir selection, linuxrc typos, ifconfig peculiarities
|
||||
|
||||
* Sat May 04 2002 Michael Brown <mbrown@fensystems.co.uk> 1.3-1fs
|
||||
- During %make, LIBDIR must be set for mknbi
|
||||
- Added %post scriptlet since %trigger seems not to be being triggered...
|
||||
|
||||
* Sat May 04 2002 Michael Brown <mbrown@fensystems.co.uk> 1.2-1fs
|
||||
- Added extra sources instead of requiring "make" to download them
|
||||
|
||||
* Sat May 04 2002 Michael Brown <mbrown@fensystems.co.uk> 1.1-1fs
|
||||
- First attempt at an RPM package
|
||||
|
||||
200
contrib/initrd/mknbi-set
Executable file
200
contrib/initrd/mknbi-set
Executable file
@@ -0,0 +1,200 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# $Id$
|
||||
# Maintains set of NBIs based on currently-installed kernels
|
||||
# Network card module sets are taken from /etc/mknbi-set.conf
|
||||
|
||||
use strict;
|
||||
use vars qw($verbosity);
|
||||
|
||||
use constant EB_PCI_DEVICE => 1;
|
||||
|
||||
# Utility function: calculate output id given a kernel file name and
|
||||
# space-separated list of modules
|
||||
sub calc_output_id ($$) {
|
||||
my $kernel = shift;
|
||||
my $moduleset = shift;
|
||||
my $kernel_ver = "";
|
||||
( $kernel_ver ) = ( $kernel =~ /vmlinuz-(.*)$/ );
|
||||
( my $output_id = "$moduleset".( $kernel_ver ? ".$kernel_ver" : "" ) ) =~ tr/,/./;
|
||||
return ( $kernel_ver, $output_id );
|
||||
}
|
||||
|
||||
# Utility function: read modules.pcimap-style file
|
||||
# Add modules to modulesets hash, write out dhcpd.conf fragment
|
||||
sub read_config_file ($$$$) {
|
||||
my $configfile = shift;
|
||||
my $modulesets = shift;
|
||||
my $dhcpfh = shift;
|
||||
my $alwaysuse = shift;
|
||||
|
||||
print "Scanning through $configfile for network modules...\n" if $verbosity >= 1;
|
||||
open CF, $configfile or die "Could not open $configfile: $!\n";
|
||||
chomp ( my $tempmodule = `mktemp /tmp/mknbi-set.XXXXXX` );
|
||||
chomp ( my $cwd = `pwd` ); chdir '/'; # Modprobe searches the current directory...
|
||||
print $dhcpfh " \# Generated from $configfile\n";
|
||||
while (<CF>) {
|
||||
chomp;
|
||||
next if /^[\#;]/ or /^\s*$/;
|
||||
( my $module, undef, my $vendor, my $device ) = /^(\S+)(\s+(\S+)\s+(\S+))?/ ;
|
||||
$modulesets->{$module} = 1 if $alwaysuse;
|
||||
if ( ! exists $modulesets->{$module} ) {
|
||||
# Check to see if module is a network module
|
||||
# Only do this the first time we encounter a module
|
||||
my @modulepaths = `/sbin/modprobe -l $module.o*` ;
|
||||
chomp ( my $modulepath = $modulepaths[0] );
|
||||
if ( $modulepath ) {
|
||||
if ( $modulepath =~ /.o.gz$/ ) {
|
||||
system ( "zcat $modulepath > $tempmodule" );
|
||||
} else {
|
||||
system ( "cp $modulepath $tempmodule" );
|
||||
}
|
||||
$modulesets->{$module} = 0;
|
||||
foreach ( `nm $tempmodule` ) {
|
||||
chomp;
|
||||
$modulesets->{$module} = 1 if /(ether|wlan)/ ;
|
||||
}
|
||||
unlink $tempmodule;
|
||||
} else {
|
||||
print STDERR "Cannot locate module $module specified in $configfile\n";
|
||||
}
|
||||
}
|
||||
if ( $modulesets->{$module} ) {
|
||||
if ( $vendor ) {
|
||||
print "$module ($vendor,$device) listed in $configfile\n" if $verbosity >= 2;
|
||||
printf $dhcpfh ( " if option etherboot.nic-dev-id = %02x:%02x:%02x:%02x:%02x { option etherboot.kmod \"%s\"; }\n",
|
||||
EB_PCI_DEVICE,
|
||||
( hex($vendor) >> 8 ) & 0xff, hex($vendor) & 0xff,
|
||||
( hex($device) >> 8 ) & 0xff, hex($device) & 0xff,
|
||||
$module );
|
||||
} else {
|
||||
print "$module (without PCI IDs) listed in $configfile\n" if $verbosity >= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
close CF;
|
||||
print $dhcpfh "\n";
|
||||
chdir $cwd;
|
||||
}
|
||||
|
||||
my $conffile = '/etc/mknbi-set.conf';
|
||||
my $mkinitrd_net = 'mkinitrd-net';
|
||||
my $mknbi = 'mknbi-linux';
|
||||
my $output_dir = '/var/lib/tftpboot';
|
||||
my $dhcpfile = '/etc/dhcpd.conf.etherboot-pcimap.include';
|
||||
my $use_local;
|
||||
our $verbosity = 1;
|
||||
my $modulesets = {};
|
||||
my $kernel = '';
|
||||
my @kernels = ();
|
||||
|
||||
my $usage="Usage: $0 [-l|--local] [-q] [-v] [-r|--refresh module[,module...]] [--help]";
|
||||
|
||||
# Parse command-line options
|
||||
while ( $_ = shift ) {
|
||||
if ( /-l|--local/ ) {
|
||||
$conffile = 'mknbi-set.conf';
|
||||
$mkinitrd_net = './mkinitrd-net';
|
||||
$mknbi = './mknbi-linux --format=nbi --target=linux';
|
||||
$output_dir = 'tftpboot';
|
||||
$dhcpfile = 'tftpboot/dhcpd.conf.etherboot-pcimap.include';
|
||||
$use_local = 1;
|
||||
} elsif ( /-r|--refresh/ ) {
|
||||
my $moduleset = shift;
|
||||
$modulesets->{$moduleset} = 1;
|
||||
} elsif ( /-k|--kernel/ ) {
|
||||
$kernel = shift;
|
||||
} elsif ( /-v|--verbose/ ) {
|
||||
$verbosity++;
|
||||
} elsif ( /-q|--quiet/ ) {
|
||||
$verbosity--;
|
||||
} elsif ( /--help/ ) {
|
||||
die "$usage\n".
|
||||
" -k, --kernel Build NBIs for a particular kernel\n".
|
||||
" -l, --local Run locally from CVS (for developers only)\n".
|
||||
" -r, --refresh Refresh NBI for a particular module\n".
|
||||
" -v, --verbose Be more verbose\n".
|
||||
" -q, --quiet Be less verbose\n";
|
||||
} else {
|
||||
die "$usage\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Get set of current kernels
|
||||
if ($kernel) {
|
||||
@kernels = ( $kernel );
|
||||
} else {
|
||||
@kernels = glob('/boot/vmlinuz*');
|
||||
}
|
||||
die "Could not find any kernels in /boot\n" unless @kernels;
|
||||
|
||||
# If modules have been specified via --refresh, do not scan for modules or rewrite the
|
||||
# dhcpd.conf fragment file
|
||||
unless ( %$modulesets ) {
|
||||
# Write dhcpd.conf fragment file
|
||||
open my $dhcpfh, ">$dhcpfile" or die "Could not open $dhcpfile for writing: $!\n";
|
||||
print $dhcpfh "# Etherboot PCI ID -> Linux kernel module mapping file\n";
|
||||
print $dhcpfh "# Generated by mknbi-set on ".(scalar localtime)."\n";
|
||||
print $dhcpfh "#\n";
|
||||
print $dhcpfh "if substring ( option vendor-class-identifier, 0, 9 ) = \"Etherboot\" {\n";
|
||||
print $dhcpfh " if exists etherboot.nic-dev-id {\n";
|
||||
print $dhcpfh " \# Legacy nic-dev-id mechanism: there are some DLink DFE538 cards in circulation that\n";
|
||||
print $dhcpfh " \# predated the change to the new nic-dev-id binary structure\n";
|
||||
print $dhcpfh " if option etherboot.nic-dev-id = \"PCI:1186:1300\" { option etherboot.kmod \"8139too\"; }\n";
|
||||
print $dhcpfh "\n";
|
||||
|
||||
# Get set of network modules to build NBIs for
|
||||
# Read explicitly-specified module sets from $conffile
|
||||
read_config_file($conffile, $modulesets, $dhcpfh, 1);
|
||||
# Obtain list of all network modules from pcimap file
|
||||
my $pcimap;
|
||||
foreach ( `/sbin/modprobe -c` ) {
|
||||
$pcimap = $1 if /^pcimap.*?=(.*)$/;
|
||||
}
|
||||
if ( $pcimap ) {
|
||||
read_config_file($pcimap, $modulesets, $dhcpfh, 0);
|
||||
} else {
|
||||
print STDERR "Could not identify pcimap file\n";
|
||||
}
|
||||
# Finish off dhcpd.conf fragment file
|
||||
print $dhcpfh " }\n}\n";
|
||||
close $dhcpfh;
|
||||
}
|
||||
|
||||
# Build initrd and nbi for each kernel-moduleset combination
|
||||
foreach my $moduleset ( sort keys %$modulesets ) {
|
||||
next unless $modulesets->{$moduleset}; # Ignore if value is 0
|
||||
print "Building NBIs for module set $moduleset\n" if $verbosity >= 1;
|
||||
foreach my $kernel ( @kernels ) {
|
||||
( my $kernel_ver, my $output_id ) = calc_output_id ( $kernel, $moduleset );
|
||||
if ( -l $kernel ) {
|
||||
# Symbolic link; create matching symlink
|
||||
my $real_kernel = readlink ( $kernel );
|
||||
( my $real_kernel_ver, my $real_output_id ) = calc_output_id ( $real_kernel, $moduleset );
|
||||
print "Symlinking $output_id to $real_output_id\n" if $verbosity >= 2;
|
||||
my $initrd_file = "$output_dir/initrd-$output_id.img";
|
||||
unlink ( $initrd_file ) if -l $initrd_file;
|
||||
system ( "ln -s initrd-$real_output_id.img $initrd_file" ) == 0 or print STDERR "Could not symlink $initrd_file to initrd-$real_output_id.img: $!\n";
|
||||
my $nbi_file = "$output_dir/boot-$output_id.nbi";
|
||||
unlink ( $nbi_file ) if -l $nbi_file;
|
||||
system ( "ln -s boot-$real_output_id.nbi $nbi_file" ) == 0 or print STDERR "Could not symlink $nbi_file to boot-$real_output_id.nbi: $!\n";
|
||||
} else {
|
||||
# Real file: create initrd and nbi
|
||||
print "Creating initrd and nbi for $output_id\n" if $verbosity >= 2;
|
||||
( my $moduleset_spaces = $moduleset ) =~ tr/,/ /;
|
||||
my $initrd_cmd = "$mkinitrd_net --nolink ".
|
||||
( $use_local ? "--local " : "" ).
|
||||
( $kernel_ver ? "--kernel $kernel_ver " : "" ).
|
||||
( $verbosity >= 2 ? "" : "-q " ).
|
||||
$moduleset_spaces;
|
||||
print "$initrd_cmd\n" if $verbosity >= 3;
|
||||
if ( system ( $initrd_cmd ) == 0 ) {
|
||||
my $mknbi_cmd = "$mknbi $kernel $output_dir/initrd-$output_id.img > $output_dir/boot-$output_id.nbi";
|
||||
print "$mknbi_cmd\n" if $verbosity >= 3;
|
||||
system ( $mknbi_cmd ) == 0 or print STDERR "mknbi failed: $!\n";
|
||||
} else {
|
||||
print STDERR "$initrd_cmd failed: $!\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
contrib/initrd/mknbi-set.conf
Normal file
27
contrib/initrd/mknbi-set.conf
Normal file
@@ -0,0 +1,27 @@
|
||||
# This file specifies the network cards for which NBI images should be built
|
||||
# Each line contains a list of kernel modules to be used, separated by commas
|
||||
# You can optionally specify PCI vendor and device IDs that should be automatically
|
||||
# mapped to this module.
|
||||
#
|
||||
# The format is similar to modutils' modules.pcimap file.
|
||||
#
|
||||
# Examples:
|
||||
# RTL8139-based ethernet card
|
||||
; 8139too
|
||||
# RTL8139-based ethernet card with PCI IDs vendor=0x1186, device=0x1300
|
||||
; 8139too 0x1186 0x1300
|
||||
# RTL8139 and Prism2_pci in same image
|
||||
; 8139too,prism2_pci
|
||||
|
||||
# Some modules do not include the MODULE_DEVICE_TABLE macro, and so end up not
|
||||
# being listed in the pcimap file. These modules are included here to force
|
||||
# the creation of corresponding initrds.
|
||||
prism2_pci 0x1260 0x3873
|
||||
prism2_plx 0x1638 0x1100
|
||||
prism2_plx 0x16ab 0x1101
|
||||
prism2_plx 0x16ab 0x1102
|
||||
prism2_plx 0x1385 0x4100
|
||||
prism2_plx 0x15e8 0x0130
|
||||
prism2_plx 0x16ec 0x3685
|
||||
prism2_plx 0x16ab 0x1102
|
||||
prism2_plx 0x15e8 0x0131
|
||||
11
contrib/initrd/script.c.patch
Normal file
11
contrib/initrd/script.c.patch
Normal file
@@ -0,0 +1,11 @@
|
||||
--- script.c.orig Tue Apr 2 23:49:33 2002
|
||||
+++ script.c Wed Jun 5 14:17:22 2002
|
||||
@@ -179,7 +179,7 @@
|
||||
}
|
||||
if (packet->siaddr) {
|
||||
envp[j] = malloc(sizeof("siaddr=255.255.255.255"));
|
||||
- sprintip(envp[j++], "siaddr=", (unsigned char *) &packet->yiaddr);
|
||||
+ sprintip(envp[j++], "siaddr=", (unsigned char *) &packet->siaddr);
|
||||
}
|
||||
if (!(over & FILE_FIELD) && packet->file[0]) {
|
||||
/* watch out for invalid packets */
|
||||
25
contrib/initrd/udhcpc-post
Normal file
25
contrib/initrd/udhcpc-post
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
# $Id$
|
||||
|
||||
if [ "$1" = "deconfig" ]; then
|
||||
ifconfig $interface 0.0.0.0 up
|
||||
else if [ "$1" = "bound" ] ; then
|
||||
echo UDHCPC: I am $ip [$hostname], booting from $serverid
|
||||
[ -n "$hostname" ] && echo $hostname > /proc/sys/kernel/hostname
|
||||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
|
||||
[ -n "$subnet" ] && NETMASK="netmask $subnet"
|
||||
ifconfig $interface $ip $BROADCAST $NETMASK
|
||||
route add default gw $router dev $interface
|
||||
echo -n > /etc/resolv.conf
|
||||
for i in $dns; do
|
||||
echo nameserver $i >> /etc/resolv.conf
|
||||
done
|
||||
[ -n "$siaddr" ] || siaddr=$serverid
|
||||
[ -n "$rootpath" ] || rootpath=$siaddr:/
|
||||
echo Mounting root filesystem $rootpath at /sysroot
|
||||
echo If this appears to hang, check that the server of $rootpath is able to
|
||||
echo reverse-map my IP address $ip to obtain my hostname $hostname
|
||||
mount -t nfs -o nolock,rsize=8192,wsize=8192 $rootpath /sysroot
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user