#!/bin/bash -e
# **build_pxe_env.sh**
# Create a PXE boot environment
#
# build_pxe_env.sh destdir
#
# Requires Ubuntu Oneiric
#
# Only needs to run as root if the destdir permissions require it
dpkg -l syslinux || apt-get install -y syslinux
DEST_DIR=${1:-/tmp}/tftpboot
PXEDIR=${PXEDIR:-/opt/ramstack/pxe}
PROGDIR=`dirname $0`
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then
umount $MNTDIR
rmdir $MNTDIR
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
mkdir -p $DEST_DIR/pxelinux.cfg
cd $DEST_DIR
for i in memdisk menu.c32 pxelinux.0; do
cp -pu /usr/lib/syslinux/$i $DEST_DIR
done
CFG=$DEST_DIR/pxelinux.cfg/default
cat >$CFG <