#!/bin/bash
#TODO:
#Set up dhcp server according to the server IP and range provided
if [ "$USER" != "root" ]; then
echo "You have to be root to run this script"
exit
fi
#Set up variables as per your taste
KIWIPATH="/usr/share/kiwi/image/kwltsp-suse-10.2"
DESTPATH="/srv/kiwi-ltsp"
TFTPBOOTPATH="/srv/tftpboot"
TMPPATH="/tmp/kiwi-netboot"
KIWINBPATH="/usr/share/kiwi/image/netboot/suse-10.2"
echo "Please enter your server IP address"
read SERVER_IP
echo "Creating KIWI-LTSP image"
kiwi --prepare $KIWIPATH --root $DESTPATH || exit
echo "setting up nfs exports"
sh $KIWIPATH/setup-exports.sh
echo "updating sshkeys of the KIWI LTSP image"
sh $KIWIPATH/ltsp-update-sshkeys
echo "Now creating KIWI-Netboot image"
kiwi --prepare $KIWINBPATH --root $TMPPATH || exit
kiwi --create $TMPPATH -d $TFTPBOOTPATH/boot/ || exit
pushd $TFTPBOOTPATH/boot/
mv initrd-netboot-suse-10.2*.gz initrd
mv initrd-netboot-suse-10.2*.kernel* linux
mv initrd-netboot-suse-10.2*.md5 linux.md5
popd
echo "NFSROOT=$SERVER_IP;$DESTPATH" > $TFTPBOOTPATH/KIWI/config.default
echo "Change the server IP in /srv/kiwi-ltsp/etc/hosts file, leave the server's hostname as it is there"
echo "Please recheck your tftp, nfsserver and dhcpd configurations"
echo "Set up complete"