#!/bin/sh
#
#	Make Linux Netinstall Image
#	Takes a RedHat or TurboLinux CD and creates a network bootable image
#
#	mklnim outputfile [path-to-cdrom]
#
#	path-to-cdrom defaults to /mnt/cdrom
#
if [ $# -lt 1 ]
then
	echo Usage: $0 outputfile [path-to-cdrom]
	exit 1
fi
pathtocdrom=${2:-"/mnt/cdrom"}
trap '' INT
tmpmount=/tmp/lnim.$$
mkdir $tmpmount
if [ -r $pathtocdrom/images/cdboot.img ]
then
	bootfloppyimage="$pathtocdrom/images/cdboot.img"
	echo TurboLinux CDROM
elif [ -r $pathtocdrom/images/boot.img ]
then
	bootfloppyimage="$pathtocdrom/images/boot.img"
	echo RedHat CDROM
else
	echo Cannot find either TurboLinux or RedHat CD
	trap INT
	exit 1
fi
mount -t msdos -o loop,ro $bootfloppyimage $tmpmount
mknbi-linux -k $tmpmount/vmlinuz -r $tmpmount/initrd.img -o $1 -x
umount $tmpmount
rmdir $tmpmount
trap INT
