Cover V03, I01
Article
Listing 1
Sidebar 1
Sidebar 2

jan94.tar


Listing 1: loadscript

#!/bin/sh

#HARRIS SPACE SYSTEMS CORP, ROCKLEDGE, FL
#PACKEY VELLECA 3/26/93
#DEVELOPED ON AN ULTRIX SYSTEM 4.2A+.
#RESTORE FILESYSTEM DUMPS FROM A SCSI TAPE
#TO A SCSI BOOT DISK.  ASSUMES BOOT-DISK IS SCSI ID#0
#AND TAPE IS SCSI ID#5.

#PROMPT OPERATOR FOR SLAVE-SPECIFIC DATA TO UPDATE
#GENERIC FILES.
#GET HOSTNAME, IP ADDRESS, AND SWAP SIZE:

echo -n "What is target hostname? "
read hn
echo -n "What is target IP address? "
read hip
echo " "
echo "What size SWAP partition in 512b sectors?"
echo "Choice is   380700 sectors (190MB),"
echo -n "or          610000 sectors (300MB): "
read bsize

#ULTRIX DISKS HAVE 8 PARTITIONS BY DEFAULT.  WE USE 4:
#'A' FOR '/', 'B' FOR 'SWAP', 'C' AS WHOLE DISK,
#AND 'D' FOR '/USR'.  THE REST ARE NOT USED.
#IN USE, PARTITION 'A' IS FIXED SIZE.
#OPERATOR CAN CHOOSE SIZE OF 'B' WHICH THEN
#DETERMINES THE SIZE OF 'D':

if [ ${bsize} = "610000" ]; then
dstart="643210"
dsize="649550"
else
dstart="413910"
dsize="878850"
fi

#COPY TAPE TO DISK.
#THE INITIAL MKFS IS FOR NEW (NO PREVIOUS FILESYSTEMS,
#OR NEWLY FORMATTED) DISKS.  THE DEFAULT SIZE FOR
#PARTITION 'A' IS 32768. IF THE DISK IS NEW, IT CANT
#BE PARTITIONED UNTIL SPACE IS ALLOCATED. MKFS WILL
#READ THE DEFAULT PARTITION TABLE FROM THE DISK
#DEVICE DRIVER, AND WRITE IT TO THE DISK.
#
#DO NOT CHANGE 32768- IT IS ONLY A TEMPORARY SIZE TO
#ALLOW PARTITIONING!!

/etc/mkfs /dev/rrz0a 32768
/etc/chpt -pa 0 33210 /dev/rrz0c
/etc/chpt -pb 33210 ${bsize} /dev/rrz0c
/etc/chpt -pc 0 1299174 /dev/rrz0c
/etc/chpt -pd ${dstart} ${dsize} /dev/rrz0c
/etc/chpt -pe 0 0 /dev/rrz0c
/etc/chpt -pf 0 0 /dev/rrz0c
/etc/chpt -pg 0 0 /dev/rrz0c
/etc/chpt -ph 0 0 /dev/rrz0c

#COPY THE BOOT BLOCKS FROM THE MINIROOT FILESYSTEM
#TO THE FIRST SECTORS (0-15)
#OF THE BOOT PARTITION, WHICH IS 'A' IN ULTRIX.

dd if=/bootblks of=/dev/rrz0a

#CREATE THE FINAL FILESYSTEMS WITH THE SELECTED SIZES.

/etc/mkfs /dev/rrz0a 33210
/etc/mkfs /dev/rrz0d ${dsize}

#DON'T WORRY ABOUT TAPE POSITION, IT'S DONE BY THE
#OPERATOR AS PART OF THE PROCEDURE. RESTORE ROOT '/'
#FILESYSTEM, NOTE TAPE DEVICE MUST BE NO-REWIND!

/etc/mount /dev/rz0a /mnt
cd /mnt
/bin/restore rf /dev/nrmt0h

#MOUNT 'A' ON /TMP SO THAT 'RESTORE' WILL HAVE ENOUGH
#SPACE TO FINISH RESTORING THE OTHER PARTITIONS.
#OTHERWISE THE MINIROOT DOESNT PROVIDE ENOUGH
#WORKSPACE, AND RESTORE WILL CRASH. ALSO NEED
#SOME COMMANDS OFF BOOT DISK FOR USE LATER IN SCRIPT.

cd /
/etc/umount /dev/rz0a
/etc/mount /dev/rz0a /tmp

#RESTORE '/USR' PARTITION

/etc/mount /dev/rz0d /mnt
cd /mnt
/bin/restore rf /dev/nrmt0h

#CHANGE GENERIC FILES ON THE NEWLY CREATED SLAVE
#BOOT-DISK USING THE COMMANDS ON THE BOOT-DISK
#ROOT PARTITION.
#MODIFY SLAVE HOSTNAME:

/tmp/bin/cp /tmp/etc/rc.local /tmp/rc.local
/tmp/bin/sed -e "s'^/bin/hostname.*' \
/bin/hostname ${hn}'"</tmp/rc.local>/tmp/etc/rc.local
rm -f /tmp/rc.local

#MODIFY SLAVE IP ADDRESS:

/tmp/bin/echo ${hip}"   "${hn}>>/tmp/etc/hosts

#REMOVE GARBAGE LEFT BY RESTORE

rm -f /tmp/restoresymtable

#SHUTDOWN NICELY. OPERATOR WILL THEN BOOT SYSTEM:

cd /
/etc/umount /dev/rz0a
/etc/umount /dev/rz0d
/etc/fsck -y /dev/rz0a
/etc/fsck -y /dev/rz0d
sync
sync
/etc/halt

#END OF SCRIPT LOADSCRIPT