Ubuntu LiveCD PXE boot (Ubuntu Live CD boot from network)

DEFAULT_URL=http://releases.ubuntu.com/releases/12.04/ubuntu-12.04-desktop-i386.iso
NFS_SERVER=192.168.1.9

if [ ! -z $1 ]; then
FILE=$1

if [ ! -f ${FILE} ]; then
echo "File ${FILE} not found"
exit 0
fi
else
URL=${DEFAULT_URL}
wget ${URL} -P /tmp
FILE=/tmp/${URL##*/}
fi

# set parameter
ISO=${FILE##*/}
DISTRO=${ISO%.*}
DISTRO=${DISTRO//desktop/live}

echo "create ${DISTRO}"

echo "copy files..."
mount ${FILE} /mnt/ -o loop
mkdir /var/lib/tftpboot/${DISTRO}
cp -a /mnt/casper/ /var/lib/tftpboot/${DISTRO}
umount /mnt

echo "configure and restart nfs..."
echo "/var/lib/tftpboot/${DISTRO} *(ro,sync,no_subtree_check)" >> /etc/exports
/etc/init.d/nfs-kernel-server restart

echo "confiure tftpboot..."
cat < /var/lib/tftpboot/pxelinux.cfg/${DISTRO}.conf
LABEL linux
MENU LABEL Ubuntu Live (${DISTRO})
KERNEL /${DISTRO}/casper/vmlinuz
# APPEND initrd=/${DISTRO}/casper/initrd.gz boot=casper netboot=nfs nfsroot=${NFS_SERVER}:/var/lib/tftpboot/${DISTRO} quiet splash locale=de_DE bootkbd=de console-setup/layoutcode=de --
APPEND initrd=/${DISTRO}/casper/initrd.lz boot=casper netboot=nfs nfsroot=${NFS_SERVER}:/var/lib/tftpboot/${DISTRO} quiet splash locale=de_DE bootkbd=de console-setup/layoutcode=de --
IPAPPEND 2
EOF

echo "MENU INCLUDE pxelinux.cfg/${DISTRO}.conf" >> /var/lib/tftpboot/pxelinux.cfg/default

# LINKS
# https://help.ubuntu.com/community/BootOptions
# http://manpages.ubuntu.com/manpages/intrepid/man7/casper.html