#!/bin/ksh
#
# This script can be used to accomodate small differences that occur
# when windows rebuilds its driver data base to accomodate different
# computers. Run this script for ech different type of compter and
# save the resulting diff file so that the computer will boot correctly.
# The first argument is the name of the client machine for which the
# diff is to be obtained. This program should only be
# run on the master image server. (ie. nermal or io)
#
IMAGE_DIR=/diskless/rootfs/winboot
if [ $# -ne 2 ] ; then
echo Error: arg count
echo Usage: $0 win98_client image_file
exit 1
fi
WIN98CLIENT=$1
TEST_IMAGE=$2
if [ ! -f "$IMAGE_DIR/$TEST_IMAGE" ] ; then
echo Cannot find file: $IMAGE_DIR/$TEST_IMAGE
exit 1
fi
# get rid of old semaphore directory that might be lying around
rm -r /diskless/rootfs/winboot/semaphores/$WIN98CLIENT
while true ; do
if ! mkdir /diskless/rootfs/winboot/semaphores/$WIN98CLIENT ; then
echo Cannot create directory.
exit 1
fi
echo $TEST_IMAGE >/diskless/rootfs/winboot/semaphores/$WIN98CLIENT/test_image
DIFF_FILE="/diskless/rootfs/winboot/diffs/$WIN98CLIENT"
if [ -O "$DIFF_FILE" ] ; then
mv $DIFF_FILE ${DIFF_FILE}.old
mv ${DIFF_FILE}.header ${DIFF_FILE}.header.old
fi
echo "Now reboot the specific computer that you want to make an image for"
echo "and allow the boot up process to update the disk image with the "
echo "specified image without applying system specific diffs."
echo "Login as an administrative user to Windows'98. The idea is to allow"
echo "windows'98 to rebuild the new driver database for the specific hardware"
echo "that is in this computer. Go through whatever proceedures are"
echo "necessary to get the system working under the new image. Note"
echo "this may require that the machine be booted multiple times."
echo "When you are ready to take a diff snapshot type 'y' at the prompt"
echo "making sure that the pc is displaying the kdm login screen."
echo
echo "Start by rebooting computer and logging into win98. Once you have"
echo "started type 'y' at the prompt to enable mutli-boot mode."
echo
echo -n "multi-boot mode? (y or n) "
read ready
if [ "$ready" = "y" ] ; then
touch /diskless/rootfs/winboot/semaphores/$WIN98CLIENT/quickboot
fi
echo
echo "Once you are satified with the image and want to get out of"
echo "multi-boot mode so that you can get an image diff type 'y' below."
echo "If you type 'n' the diff will be aborted."
echo
echo -n "continue? (y or n) "
read ready
if [ "$ready" = "n" ] ; then
if [ -O "${DIFF_FILE}.old" ] ; then
mv ${DIFF_FILE}.old ${DIFF_FILE}
mv ${DIFF_FILE}.header.old ${DIFF_FILE}.header
fi
rm -r /diskless/rootfs/winboot/semaphores/$WIN98CLIENT
exit 1
fi
rm -f /diskless/rootfs/winboot/semaphores/$WIN98CLIENT/quickboot
touch /diskless/rootfs/winboot/semaphores/$WIN98CLIENT/no_sync
echo
echo "Once the linux login screen has appeared type 'y' at the prompt to"
echo "continue with the creation of the diff image or 'n' to abort."
echo
echo -n "continue? (y or n) "
read ready
if [ "$ready" = "n" ] ; then
if [ -O "${DIFF_FILE}.old" ] ; then
mv ${DIFF_FILE}.old ${DIFF_FILE}
mv ${DIFF_FILE}.header.old ${DIFF_FILE}.header
fi
rm -r /diskless/rootfs/winboot/semaphores/$WIN98CLIENT
exit 1
fi
while true ; do
echo "Testing ssh to $WIN98CLIENT (This may take a few minutes)"
tst=`ssh $WIN98CLIENT echo "hello world"`
if [ "$tst" = "hello world" ] ; then
break
fi
echo -n "cannot connect to server, try again: (y or n) "
read again
if [ "$again" = "n" ] ; then
exit 1
fi
done
echo ssh working...
echo doing a diff on the current disk image...
ssh $WIN98CLIENT /sbin/img_diff /dev/hda1 /winboot/$TEST_IMAGE.sum /tmp/diff
scp ${WIN98CLIENT}:/tmp/diff $IMAGE_DIR/diffs/${WIN98CLIENT}
scp ${WIN98CLIENT}:/tmp/diff.header $IMAGE_DIR/diffs/${WIN98CLIENT}.header
ssh $WIN98CLIENT rm /tmp/diff /tmp/diff.header
rm -f /diskless/rootfs/winboot/semaphores/$WIN98CLIENT/no_sync
echo
echo "The image_sync should now include the diff file just created so"
echo "that the image should work with this compter hardware. Try rebooting"
echo "the computer and logging into Windows'98 to see if windows comes up"
echo "normally. If it comes up normally type 'q' at the prompt below or 'y'"
echo "if you want to try another rebuild."
echo
echo -n "again or quit (y or q)? "
read ready
if [ ! "$ready" = "y" ] ; then
echo "Note that this computer will not boot properly if the"
echo "test image is not installed as the default image. Also note"
echo "that you can allow similar computers to use this hybrid"
echo "image by making a symlink to the following diff file:"
echo " /diskless/rootfs/winboot/diffs/$WIN98CLIENT"
echo "The name of the symlink should be the hostname of the"
echo "computer."
rm -r /diskless/rootfs/winboot/semaphores/$WIN98CLIENT
exit 0
fi
rm -r /diskless/rootfs/winboot/semaphores/$WIN98CLIENT
done