how to create LTSP boot images

this Makefile creates CD or USB stick lenny boot images to turn any PC into an LTSP client. Run it on the lenny LTSP server. Needs live-helper.

the images can be downloaded from http://livecd.phys.ethz.ch/ and burnt to CD or dd'ed to a USB stick.

Makefile:

 # copyright 2008 Christian Herzog <daduke@daduke.org>, distributed under
 # the terms of the GNU General Public License version 2 or any later version.

usb: clean config.usb rest
cd: clean config.cd rest

clean:
        rm -rf binary/  binary.*  cache/  chroot/  config/ .stage/

config.usb:
        lh_config -d lenny -a i386 -b usb-hdd --mirror-bootstrap "http://debian.ethz.ch/mirror/debian/" --mirror-binary "http://debian.ethz.ch/mirror/debian/" --mirror-chroot-sec
urity "http://debian.ethz.ch/mirror/debian-security/" --mirror-binary-security "http://debian.ethz.ch/mirror/debian-security" --syslinux-splash splash.rle --packages "ltspfsd ldm
 console-setup console-terminus lsb-release mkelfimage nbd-client syslinux tftp-hpa openssh-server openssh-client xserver-xorg console-setup nbd-client zsh less mc rdesktop scree
n"

config.cd:
        lh_config -d lenny -a i386 --mirror-bootstrap "http://debian.ethz.ch/mirror/debian/" --mirror-binary "http://debian.ethz.ch/mirror/debian/" --mirror-chroot-security "http
://debian.ethz.ch/mirror/debian-security/" --mirror-binary-security "http://debian.ethz.ch/mirror/debian-security" --bootloader grub --grub-splash splash.xpm.gz --packages "ltspf
sd ldm console-setup console-terminus lsb-release mkelfimage nbd-client syslinux tftp-hpa openssh-server openssh-client xserver-xorg console-setup nbd-client zsh less mc rdesktop
 screen"

rest:
        mkdir -p config/chroot_local-includes/etc
        cp /pub/debian-local/configs/lenny/plimpy/lts.conf config/chroot_local-includes/etc/                                    #copy our lts.conf
        perl -pi -e 's/LOCALDEV/LDM_SERVER = plimpy.ethz.ch\n\tLOCALDEV/' config/chroot_local-includes/etc/lts.conf             #insert ltsp server
        touch config/chroot_local-includes/etc/ltsp_chroot                                                                      #enable ltsp-client install magic
        perl -pi -e 's/^LH_UNION_FILESYSTEM=.+$$/LH_UNION_FILESYSTEM="aufs"/' config/chroot                                     #for lenny, we need aufs
        perl -pi -e 's/^LH_LINUX_PACKAGES=.+$$/LH_LINUX_PACKAGES="linux-image-2.6 aufs-modules-2.6 squashfs-modules-2.6"/' config/chroot

        lh_bootstrap                                                                                                            #prep chroot
        lh_chroot
        lh_clean --binary
        echo "nameserver 129.132.98.12" >> chroot/etc/resolv.conf
        chroot chroot/ bash -c "ping -c 1 debian.ethz.ch ; aptitude install ltsp-client-core"
        mkdir foo                                                                                                               #ltsp-update-sshkeys needs the chroot one director
y deeper
        mv chroot foo/
        ltsp-update-sshkeys -b foo/
        mv foo/chroot .                                                                                                         #.. and back
        rmdir foo
        cp -R /opt/ltsp/i386/usr/share/ldm/themes/DPHYS/ chroot/usr/share/ldm/themes                                            #copy our ldm theme
        cp /pub/debian-local/configs/lenny/plimpy/geode_drv.so chroot/usr/lib/xorg/modules/drivers                              #copy geode X11 driver
        rm chroot/usr/share/ldm/themes/default
        cd chroot/usr/share/ldm/themes/ && ln -s DPHYS default                                                                  #symlink it
        perl -pi -e 's/plimpy /plimpy.ethz.ch /' chroot/etc/ssh/ssh_known_hosts                                                 #we need a FQH in known_hosts
        lh_binary                                                                                                               #create the image

the Makefile for ppc is slightly different:

 # copyright 2008 Christian Herzog <daduke@daduke.org>, distributed under
 # the terms of the GNU General Public License version 2 or any later version.

all: clean config.cd rest

clean:
        rm -rf binary/  binary.*  cache/  chroot/  config/ .stage/

config.cd:
        lh_config -d lenny --mirror-bootstrap "http://debian.ethz.ch/mirror/debian/" --mirror-binary "http://debian.ethz.ch
/mirror/debian/"

rest:
        wget deb http://pkg-ltsp.alioth.debian.org/debian/pkg-ltsp-keyring -O config/chroot_sources/ltsp.bootstrap.gpg
        wget deb http://pkg-ltsp.alioth.debian.org/debian/pkg-ltsp-keyring -O config/chroot_sources/ltsp.binary.gpg
        echo openssh-server xserver-xorg console-setup nbd-client >> config/chroot_local-packageslists/xorg
     #some base packages
        mkdir -p config/chroot_local-includes/etc
        scp kneazle:/pub/debian-local/configs/etch/plimpy/lts.conf config/chroot_local-includes/etc/
             #copy our lts.conf
        perl -pi -e 's/LOCALDEV/LDM_SERVER = plimpy.ethz.ch\n\tLOCALDEV/' config/chroot_local-includes/etc/lts.conf
     #insert ltsp server
        touch config/chroot_local-includes/etc/ltsp_chroot
     #enable ltsp-client install magic
        perl -pi -e 's/^LH_UNION_FILESYSTEM=.+$$/LH_UNION_FILESYSTEM="aufs"/' config/chroot
     #for lenny, we need aufs
        perl -pi -e 's/^LH_LINUX_PACKAGES=.+$$/LH_LINUX_PACKAGES="linux-image-2.6 aufs-modules-2.6 squashfs-modules-2.6"/'
config/chroot

        lh_bootstrap
     #prep chroot
        lh_chroot
        lh_clean --binary
        chroot chroot/ aptitude -y install ltsp-client-core ltspfsd ldm
     #install ltsp packages in chroot
        chroot chroot/ dpkg -P xserver-xorg-video-vga xserver-xorg-video-all
     #remove xorg vga driver to enable proper HW detection
        #mkdir foo
     #ltsp-update-sshkeys needs the chroot one directory deeper
        #mv chroot foo/
        #ltsp-update-sshkeys -b foo/
        #mv foo/chroot .
             #.. and back
        #rmdir foo
        scp plimpy:/scratch/ltsp-live-cd/chroot/etc/ssh/ssh_known_hosts chroot/etc/ssh/
             #get plimpy ssh keys
        -scp -r plimpy:/opt/ltsp/i386/usr/share/ldm/themes/DPHYS/ chroot/usr/share/ldm/themes
             #copy our ldm theme
        rm chroot/usr/share/ldm/themes/default
        cd chroot/usr/share/ldm/themes/ && ln -s DPHYS default
     #symlink it
        perl -pi -e 's/plimpy /plimpy.ethz.ch /' chroot/etc/ssh/ssh_known_hosts
     #we need a FQH in known_hosts
        lh_binary
     #create the image

if you've still got an LTSP server running etch, the Makefile is somewhat different:

 # copyright 2008 Christian Herzog <daduke@daduke.org>, distributed under
 # the terms of the GNU General Public License version 2 or any later version.

usb: clean config.usb rest
cd: clean config.cd rest

clean:
        rm -rf binary/  binary.*  cache/  chroot/  config/ .stage/

config.usb:
        lh_config -d lenny -b usb-hdd --mirror-bootstrap "http://debian.ethz.ch/mirror/debian/" \
        --mirror-binary "http://debian.ethz.ch/mirror/debian/" \
        --mirror-bootstrap-security "http://debian.ethz.ch/mirror/debian-security/" \
        --mirror-binary-security "http://debian.ethz.ch/mirror/debian-security" \
        --syslinux-splash splash.rle

config.cd:
        lh_config -d lenny --mirror-bootstrap "http://debian.ethz.ch/mirror/debian/" \
        --mirror-binary "http://debian.ethz.ch/mirror/debian/" \
        --mirror-bootstrap-security "http://debian.ethz.ch/mirror/debian-security/" \
        --mirror-binary-security "http://debian.ethz.ch/mirror/debian-security" \
        --bootloader grub --grub-splash splash.xpm.gz

rest:
        echo deb http://pkg-ltsp.alioth.debian.org/debian etch-ltsp-backports main \
        >> config/chroot_sources/ltsp.bootstrap
                #use ETH debian mirrors
        echo deb http://pkg-ltsp.alioth.debian.org/debian etch-ltsp-backports main \
        >> config/chroot_sources/ltsp.binary
        wget deb http://pkg-ltsp.alioth.debian.org/debian/pkg-ltsp-keyring \
        -O config/chroot_sources/ltsp.bootstrap.gpg
        wget deb http://pkg-ltsp.alioth.debian.org/debian/pkg-ltsp-keyring \
        -O config/chroot_sources/ltsp.binary.gpg
        echo openssh-server xserver-xorg console-setup nbd-client \
        >> config/chroot_local-packageslists/xorg
                #some base packages
        mkdir -p config/chroot_local-includes/etc
        cp /pub/debian-local/configs/etch/plimpy/lts.conf \
        config/chroot_local-includes/etc/
                #copy our lts.conf
        perl -pi -e 's/LOCALDEV/LDM_SERVER = plimpy.ethz.ch\n\tLOCALDEV/' \
        config/chroot_local-includes/etc/lts.conf
                #insert ltsp server
        touch config/chroot_local-includes/etc/ltsp_chroot
                #enable ltsp-client install magic
        perl -pi -e 's/^LH_UNION_FILESYSTEM=.+$$/LH_UNION_FILESYSTEM="aufs"/' config/chroot
                #for lenny, we need aufs
        perl -pi -e 's/^LH_LINUX_PACKAGES=.+$$/LH_LINUX_PACKAGES="linux-image-2.6 aufs-modules-2.6 squashfs-modules-2.6"/' \
        config/chroot

        lh_bootstrap        #prep chroot
        lh_chroot
        lh_clean binary
        chroot chroot/ aptitude -y install ltsp-client-core ltspfsd ldm
                #install ltsp packages in chroot
        mkdir foo        #ltsp-update-sshkeys needs the chroot one directory deeper
        mv chroot foo/
        ltsp-update-sshkeys -b foo/
        mv foo/chroot .        #.. and back
        rmdir foo
        cp -R /opt/ltsp/i386/usr/share/ldm/themes/DPHYS chroot/usr/share/ldm/themes
                #copy our ldm theme
        rm chroot/usr/share/ldm/themes/default
        cd chroot/usr/share/ldm/themes/ && ln -s DPHYS default
                #symlink it
        perl -pi -e 's/plimpy /plimpy.ethz.ch /' chroot/etc/ssh/ssh_known_hosts
                #we need a FQH in known_hosts
        lh_binary
                #create the image