devstack_custom/build_pxe_boot.sh

114 lines
2.5 KiB
Bash
Raw Normal View History

2011-09-27 22:53:11 +00:00
#!/bin/bash
2011-09-28 19:14:33 +00:00
# build_pxe_boot.sh - Create a PXE boot environment
2011-09-27 22:53:11 +00:00
#
2011-09-29 21:15:23 +00:00
# build_pxe_boot.sh [-k kernel-version] destdir
2011-09-27 22:53:11 +00:00
#
# Assumes syslinux is installed
2011-09-29 21:15:23 +00:00
# Assumes devstack files are in `pwd`/pxe
2011-09-28 19:14:33 +00:00
# Only needs to run as root if the destdir permissions require it
2011-09-27 22:53:11 +00:00
UBUNTU_MIRROR=http://archive.ubuntu.com/ubuntu/dists/natty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
2011-09-28 03:19:32 +00:00
MEMTEST_VER=4.10
MEMTEST_BIN=memtest86+-${MEMTEST_VER}.bin
MEMTEST_URL=http://www.memtest.org/download/${MEMTEST_VER}/
2011-09-29 21:15:23 +00:00
KVER=`uname -r`
if [ "$1" = "-k" ]; then
KVER=$2
shift;shift
fi
2011-09-28 03:19:32 +00:00
DEST_DIR=${1:-/tmp}/tftpboot
2011-09-27 22:53:11 +00:00
OPWD=`pwd`
2011-09-29 21:15:23 +00:00
PROGDIR=`dirname $0`
2011-09-27 22:53:11 +00:00
2011-09-28 03:19:32 +00:00
mkdir -p $DEST_DIR/pxelinux.cfg
cd $DEST_DIR
for i in memdisk menu.c32 pxelinux.0; do
cp -p /usr/lib/syslinux/$i $DEST_DIR
done
2011-09-27 22:53:11 +00:00
DEFAULT=$DEST_DIR/pxelinux.cfg/default
cat >$DEFAULT <<EOF
default menu.c32
prompt 0
2011-09-28 19:14:33 +00:00
timeout 0
2011-09-27 22:53:11 +00:00
MENU TITLE PXE Boot Menu
EOF
2011-09-29 21:15:23 +00:00
# Setup devstack boot
2011-09-27 22:53:11 +00:00
mkdir -p $DEST_DIR/ubuntu
2011-09-29 21:15:23 +00:00
if [ ! -d $OPWD/pxe ]; then
mkdir -p $OPWD/pxe
fi
if [ ! -r $OPWD/pxe/vmlinuz-${KVER}-generic ]; then
if [ ! -r /boot/vmlinuz-${KVER}-generic ]; then
echo "No kernel found"
else
cp -p /boot/vmlinuz-${KVER}-generic $OPWD/pxe
fi
fi
cp -p $OPWD/pxe/vmlinuz-${KVER}-generic $DEST_DIR/ubuntu
if [ ! -r $OPWD/pxe/stack-initrd.gz ]; then
$PROGDIR/build_pxe_ramdisk.sh $OPWD/pxe/stack-initrd.gz
fi
cp -p $OPWD/pxe/stack-initrd.gz $DEST_DIR/ubuntu
cat >>$DEFAULT <<EOF
LABEL devstack
MENU LABEL ^devstack
MENU DEFAULT
KERNEL ubuntu/vmlinuz-$KVER-generic
APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
EOF
# Get Ubuntu
if [ -d $OPWD/pxe ]; then
cp -p $OPWD/pxe/natty-min-initrd.gz $DEST_DIR/ubuntu
fi
2011-09-27 22:53:11 +00:00
cat >>$DEFAULT <<EOF
LABEL ubuntu
2011-09-29 21:15:23 +00:00
MENU LABEL ^Ubuntu Natty
KERNEL ubuntu/vmlinuz-$KVER-generic
APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
2011-09-27 22:53:11 +00:00
EOF
2011-09-28 03:19:32 +00:00
# Get Memtest
cd $DEST_DIR
if [ ! -r $MEMTEST_BIN ]; then
wget -N --quiet ${MEMTEST_URL}/${MEMTEST_BIN}.gz
gunzip $MEMTEST_BIN
fi
cat >>$DEFAULT <<EOF
LABEL memtest
2011-09-29 21:15:23 +00:00
MENU LABEL ^Memtest86+
2011-09-28 03:19:32 +00:00
KERNEL $MEMTEST_BIN
EOF
2011-09-27 22:53:11 +00:00
# Get FreeDOS
mkdir -p $DEST_DIR/freedos
cd $DEST_DIR/freedos
wget -N --quiet http://www.fdos.org/bootdisks/autogen/FDSTD.288.gz
gunzip -f FDSTD.288.gz
cat >>$DEFAULT <<EOF
LABEL freedos
MENU LABEL ^FreeDOS bootdisk
KERNEL memdisk
APPEND initrd=freedos/FDSTD.288
EOF
2011-09-28 03:19:32 +00:00
# Local disk boot
cat >>$DEFAULT <<EOF
LABEL local
2011-09-29 21:15:23 +00:00
MENU LABEL ^Local disk
2011-09-28 03:19:32 +00:00
MENU DEFAULT
LOCALBOOT 0
EOF