#!gpxe
#############################################################################
# gpxe script to boot LTSP clients even on circumstances where there's no   #
# control over the DHCP server, e.g. on a corporate environment, or if a    #
# cheap modem/router is used as a DHCP server, or even if there's no DHCP   #
# server running at all.                                                    #
# copyright 2009 Alkis Georgopoulos <http://users.sch.gr/alkisg/>           #
# distributed under the terms of the GNU General Public License version 3   #
# or any later version.                                                     #
# Many thanks to the gpxe developers for making this possible, and          #
# especially to Shao Miller for adding support for gpxe scripts to be       #
# passed as initrds to gpxe.krn.                                            #
#############################################################################

# This script file instructs gpxe to use 3 different methods to boot the PC.
# Please edit the file appropriately to suit your needs.
# Of course, if autoboot succeeds, the other boot methods aren't used.


#############################################################################
# Method 1: autoboot                                                        #
#############################################################################
# autoboot is the normal way to boot PXEClients; the DHCP server should     #
# provide all the needed info, i.e. ip/netmask/next-server/filename etc.    #
#                                                                           #
# But this version of gpxe is especially patched so that autoboot tries     #
# an alternative way to boot, if the original autoboot function fails:      #
#  * if next-server isn't set, it's automatically set to x.x.x.10           #
#  * if filename isn't set, it's automatically set to /ltsp/i386/pxelinux.0 #
#  * tftp://${next-server}/${filename} is loaded and executed               #
#                                                                           #
# WARNING #1: if your DHCP server doesn't send the next-server parameter,   #
# the initscripts won't be able to locate the ltsp server to continue with  #
# the boot process. In this case, you have to append the following text:    #
#   IPAPPEND 3                                                              #
# to a new line in the /var/lib/tftpboot/ltsp/i386/pxelinux.cfg/default     #
# file. Also append the same line to the chroot:                            #
# /opt/ltsp/i386/boot/pxelinux.cfg/default                                  #
#                                                                           #
# WARNING #2: if your DHCP server doesn't send the boot filename parameter, #
# the initscripts won't be able to work out the TFTP path, and lts.conf     #
# won't be downloaded to the client. In this case, run:                     #
#   sudo ln -s ltsp/i386/lts.conf /var/lib/tftpboot/lts.conf                #
# on your server in order for the client to be able to locate lts.conf.     #
#############################################################################
autoboot


#############################################################################
# Method 2: Not configurable DHCP server                                    #
#############################################################################
# If you do have a DHCP server, but you can't modify it to send some of the #
# needed boot parameters, you could comment out the "autoboot" method above #
# and uncomment/edit some of the following commands.                        #
#                                                                           #
# The previous WARNINGs about next-server and filename apply here as well.  #
#############################################################################
echo Using DHCP server + some boot information from gpxe.txt...
dhcp net0
set next-server 10.160.31.10
set filename /ltsp/i386/pxelinux.0
echo Booting from tftp://${next-server}/${filename}
chain ${filename}


#############################################################################
# Method 3: No DHCP server at all - using static IP                         #
#############################################################################
# If you do not have or don't want to use a DHCP server, you may provide    #
# static boot information below. Of course the IP used should not collide   #
# with any DHCP server ranges.                                              #
#                                                                           #
# The previous WARNING about filename and lts.conf applies here as well.    #
#############################################################################
echo Using static boot information provided in gpxe.txt...

set net0/ip 10.160.31.101
set net0/netmask 255.255.255.0
set net0/gateway 10.160.31.1
ifopen net0
set next-server 10.160.31.10

# An example with directly loading the vmlinuz kernel is given (instead of
# using pxelinux.0 as an intermediate step).
set filename /ltsp/i386/vmlinuz

# The ip=xxx kernel parameter below is used by the ipconfig program
# to set the "permanent" ip after the kernel is booted. The format is:
# ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
# See http://codtech.com/wiki/index.php/Ipconfig for details.
# You may also pass other kernel parameters, like "vga=791 quiet splash"
# The filename parameter below is currently unused; it is passed in the hope
# that the initscripts will some day use it to correctly locate lts.conf.
echo Booting from tftp://${next-server}/${filename}
kernel /ltsp/i386/vmlinuz ro ip=${ip}:${next-server}:${gateway}:${netmask}:${hostname}:eth0:none filename=${filename} splash
initrd /ltsp/i386/initrd.img
boot vmlinuz
