home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1999 November
/
VPR9911B.ISO
/
misc
/
src
/
trees
/
mkboot
< prev
next >
Wrap
Text File
|
1999-04-19
|
2KB
|
109 lines
#!/bin/sh
if [ $(stat $0 | awk '/Device/ { print $2 }') = "0,0" ] ; then
echo "Don't run $0 over nfs!"
exit 1
fi
PATH=/sbin:$PATH
export PATH
BASEDIR=boot
SIZE=1440
SYSLINUXVER=1.43
MNTPOINT=/tmp/mkimage.mnt-$$
while [ -n "$1" ] ; do
case "$1" in
"local")
IMAGES="$IMAGES boot"
shift
;;
"network")
IMAGES="$IMAGES bootnet"
shift;
;;
-f)
FORCE=-f
shift;
;;
*)
echo "Useage:" >&2
echo "$0 [-f] [network] [local]" >&2
exit
;;
esac
done
mkdir -p ../../../images
if [ -z "$IMAGES" ]; then
IMAGES="boot bootnet"
fi
for TARGET in $IMAGES; do
IMAGE=../../../images/$TARGET.img
if [ "$FORCE" != "-f" ]; then
if [ -f $IMAGE ]; then
echo "$IMAGE already exists." >&2
continue;
fi
fi
case "$TARGET" in
"boot")
./mkinitrd local $FORCE
;;
"bootnet")
./mkinitrd network $FORCE
;;
esac
rm -f $IMAGE
dd if=/dev/zero of=$IMAGE bs=1k count=$SIZE 2> /dev/null
for devnum in 0 1 2 3 4 5 6 7 8; do
if losetup /dev/loop$devnum $IMAGE 2>/dev/null ; then break; fi
done
if [ "$devnum" = "8" ]; then
rm -rf $MNTPOINT $IMAGE
echo "All of your loopback devices are in use!" >&2
exit 1
fi
LODEV=/dev/loop$devnum
gunzip < syslinux-$SYSLINUXVER/img1440k.gz | dd of=$LODEV
# install new syslinux
syslinux-$SYSLINUXVER/syslinux $LODEV
mkdir $MNTPOINT
mount -t msdos $LODEV $MNTPOINT
(cd $BASEDIR; find . -name CVS -prune -o -print | cpio -pv $MNTPOINT)
case "$TARGET" in
"boot")
cp initrd-local.img $MNTPOINT/initrd.img
cat $BASEDIR/syslinux.cfg | sed 's/initrd.img/initrd.img local/' >\
$MNTPOINT/syslinux.cfg
;;
"bootnet")
cp initrd-network.img $MNTPOINT/initrd.img
cat $BASEDIR/syslinux.cfg | sed 's/initrd.img/initrd.img network/' >\
$MNTPOINT/syslinux.cfg
;;
esac
df $MNTPOINT
umount $MNTPOINT
losetup -d $LODEV
rm -rf $MNTPOINT
done