blob: 16fa02c0fe4e2cca4d48f88a247e8d14c71e6752 [file] [log] [blame]
Dean Troyer3f717002011-09-27 17:53:11 -05001#!/bin/bash
Dean Troyer9b5ebb52011-09-28 14:14:33 -05002# build_pxe_boot.sh - Create a PXE boot environment
Dean Troyer3f717002011-09-27 17:53:11 -05003#
Dean Troyer9b5ebb52011-09-28 14:14:33 -05004# build_pxe_boot.sh destdir
Dean Troyer3f717002011-09-27 17:53:11 -05005#
6# Assumes syslinux is installed
Dean Troyer9b5ebb52011-09-28 14:14:33 -05007# Only needs to run as root if the destdir permissions require it
Dean Troyer3f717002011-09-27 17:53:11 -05008
9UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
10
Dean Troyer1f80bfb2011-09-27 22:19:32 -050011MEMTEST_VER=4.10
12MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
13MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
14
15DEST_DIR=${1:-/tmp}/tftpboot
Dean Troyer3f717002011-09-27 17:53:11 -050016OPWD=`pwd`
17
Dean Troyer1f80bfb2011-09-27 22:19:32 -050018mkdir -p $DEST_DIR/pxelinux.cfg
19cd $DEST_DIR
20for i in memdisk menu.c32 pxelinux.0; do
21 cp -p /usr/lib/syslinux/$i $DEST_DIR
22done
23
Dean Troyer3f717002011-09-27 17:53:11 -050024DEFAULT=$DEST_DIR/pxelinux.cfg/default
25cat >$DEFAULT <<EOF
26default menu.c32
Dean Troyer3f717002011-09-27 17:53:11 -050027prompt 0
Dean Troyer9b5ebb52011-09-28 14:14:33 -050028timeout 0
Dean Troyer3f717002011-09-27 17:53:11 -050029
30MENU TITLE PXE Boot Menu
31
32EOF
33
Dean Troyer3f717002011-09-27 17:53:11 -050034# Get Ubuntu netboot
35mkdir -p $DEST_DIR/ubuntu
36cd $DEST_DIR/ubuntu
37wget -N --quiet $UBUNTU_MIRROR/linux
38wget -N --quiet $UBUNTU_MIRROR/initrd.gz
39cat >>$DEFAULT <<EOF
40
41LABEL ubuntu
42 MENU LABEL Ubuntu Natty
43 KERNEL ubuntu/linux
44 APPEND initrd=ubuntu/initrd.gz
45EOF
Dean Troyer3f717002011-09-27 17:53:11 -050046
Dean Troyer1f80bfb2011-09-27 22:19:32 -050047# Get Memtest
48cd $DEST_DIR
49if [ ! -r $MEMTEST_BIN ]; then
50 wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
51 gunzip $MEMTEST_BIN
52fi
53cat >>$DEFAULT <<EOF
54
55LABEL memtest
56 MENU LABEL Memtest86+
57 KERNEL $MEMTEST_BIN
58EOF
Dean Troyer1f80bfb2011-09-27 22:19:32 -050059
Dean Troyer3f717002011-09-27 17:53:11 -050060# Get FreeDOS
61mkdir -p $DEST_DIR/freedos
62cd $DEST_DIR/freedos
63wget -N --quiet http://www.fdos.org/bootdisks/autogen/FDSTD.288.gz
64gunzip -f FDSTD.288.gz
65cat >>$DEFAULT <<EOF
66
67LABEL freedos
68 MENU LABEL ^FreeDOS bootdisk
69 KERNEL memdisk
70 APPEND initrd=freedos/FDSTD.288
71EOF
Dean Troyer1f80bfb2011-09-27 22:19:32 -050072
73# Local disk boot
74cat >>$DEFAULT <<EOF
75
76LABEL local
77 MENU LABEL Local disk
78 MENU DEFAULT
79 LOCALBOOT 0
80EOF