exit on end-of-file if file shorter than a screen, regardless
[unix-history] / usr / src / sys / tahoe / dist / get
#!/bin/sh -
#
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by the University of California, Berkeley. The name of the
# University may not be used to endorse or promote products derived
# from this software without specific prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# @(#)get 1.5 (Berkeley) %G%
#
# Shell script to build a mini-root file system in preparation for building
# a distribution tape. The file system created here is image copied onto
# tape, then image copied onto disk as the "first" step in a cold boot of
# 4.3BSD systems.
#
DISTROOT=/nbsd
#
if [ `pwd` = '/' ]
then
echo You just '(almost)' destroyed the root
exit
fi
# copy in kernel
cp $DISTROOT/sys/GENERIC/vmunix .
# create necessary directories
DIRLIST="bin dev etc a tmp stand"
rm -rf $DIRLIST
mkdir $DIRLIST
# copy in files from /etc
ETCFILE="disklabel disktab fsck ifconfig init mknod mount newfs restore \
rrestore umount"
for i in $ETCFILE; do
cp $DISTROOT/etc/$i etc/$i
done
# copy in files from /bin
BINFILE="[ awk cat cp dd echo ed expr ls make mkdir mt mv rcp rm sh stty \
sync"
for i in $BINFILE; do
cp $DISTROOT/bin/$i bin/$i
done
ln bin/stty bin/STTY
# copy in files from /stand
STANDFILE="copy vdformat"
for i in $STANDFILE; do
cp $DISTROOT/stand/$i stand/$i
done
# copy in files from /
#DOTFILE=".profile boot fppoc fppwcs poc poc1 poc2 wcs"
DOTFILE=".profile boot wcs"
for i in $DOTFILE; do
cp $DISTROOT/$i $i
done
# initialize /dev
cp $DISTROOT/dev/MAKEDEV dev/MAKEDEV
chmod +x dev/MAKEDEV
cp /dev/null dev/MAKEDEV.local
(cd dev; ./MAKEDEV std dk0; ./MAKEDEV cy0; mv rmt12 cy0; rm *mt*)
# initialize /etc/passwd
cat >etc/passwd <<EOF
root::0:10::/:/bin/sh
EOF
# initialize /etc/group
cat >etc/group <<EOF
wheel:*:0:
staff:*:10:
EOF
# initialize /etc/fstab
cat >etc/fstab <<EOF
/dev/xfd0a:/a:xx:1:1
/dev/dk0a:/a:xx:1:1
EOF
# create xtr script
cat >xtr <<'EOF'
#!/bin/sh -e
: ${disk?'Usage: disk=xx0 tape=yy xtr'}
: ${tape?'Usage: disk=xx0 tape=yy xtr'}
echo 'Build root file system'
newfs ${disk}a
sync
echo 'Check the file system'
fsck /dev/r${disk}a
mount /dev/${disk}a /a
cd /a
echo 'Rewind tape'
mt -f /dev/${tape}0 rew
echo 'Restore the dump image of the root'
restore rsf 3 /dev/${tape}0
cd /
sync
umount /dev/${disk}a
sync
fsck /dev/r${disk}a
echo 'Root filesystem extracted'
EOF
# make xtr script executable
chmod +x xtr
sync