#!/bin/sh

set -e

# Generate the LTSP specific iPXE menu
ltsp ipxe 2> /dev/null

# Add PXE installation related entries to iPXE menu.
if ! grep -q main-server /srv/tftp/ltsp/ltsp.ipxe && \
    [ -f /srv/tftp/debian-installer/amd64/linux ] ; then
	echo "Modifying /srv/tftp/ltsp/ltsp.ipxe"
	sed -i '/^menu.*/ a item\
item --gap                        Installation:\
item --key a amd64                Install Debian Edu/amd64 (64-Bit)\
item --key i i386                 Install Debian Edu/i386  (32-Bit)\
item\
' /srv/tftp/ltsp/ltsp.ipxe
	cat /srv/tftp/debian-edu/install.cfg >>/srv/tftp/ltsp/ltsp.ipxe
fi

# Make sure /srv/tftp/ltsp/ltsp.ipxe is Debian Edu specific.
sed -i 's#ltsp/ltsp.img#ltsp/${img}/ltsp.img#' /srv/tftp/ltsp/ltsp.ipxe
echo ""
echo "/srv/tftp/ltsp/ltsp.ipxe has been modified."
