head	1.6;
access;
symbols;
locks; strict;
comment	@# @;


1.6
date	93.11.06.20.27.43;	author md;	state Exp;
branches;
next	1.5;

1.5
date	93.05.20.19.53.29;	author md;	state Exp;
branches;
next	1.4;

1.4
date	92.12.10.13.06.32;	author md;	state Exp;
branches;
next	1.3;

1.3
date	92.11.27.13.49.38;	author md;	state Exp;
branches;
next	1.2;

1.2
date	92.03.26.16.47.38;	author md;	state Exp;
branches;
next	1.1;

1.1
date	88.12.09.22.53.50;	author md;	state Exp;
branches;
next	;


desc
@original AOS version
@


1.6
log
@Correct amount of available disk space on 1.2M floppy.
@
text
@#!/bin/sh
# $Header: /usr/src/sys/rtdist/RCS/miniroot,v 1.5 1993/05/20 19:53:29 md Exp md $
# $ACIS:miniroot 12.2$
# $Source: /usr/src/sys/rtdist/RCS/miniroot,v $
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1987,1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
#	miniroot - script to build an installation miniroot
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/ibm:.
export PATH
CMD=`basename ${0}`
USAGE="
usage: ${CMD} [options]

available options:
	-f<special>	disk partition to use	[/dev/fd0]
	-m<mdir>	mountpoint to use	[/mnt]
	-k<file>	kernel binary to use	[/sys/GENERIC.rtminiroot/vmunix]
	-d<rdir>	"root" directory tree	[/]
	-local		use local datafiles (eg, /etc/hosts)
"
#
# uses Makefile to make the "local" (miniroot specific) utilities.
# Unless local is specified, tries to use /usr/src versions of datafiles
#
DEVICE=/dev/fd0
RDEVICE=/dev/rfd0
FS=/mnt
VMUNIX=/sys/GENERIC.rtminiroot/vmunix
SRC=/usr/src
ROOT=
TBUILD=/tmp/mroot.image

for i
do
	case "${i}" in
	-f?*)	DEVICE=`expr "${i}" : '-.\(.*\)'`;;
	-m?*)	FS=`expr "${i}" : '-.\(.*\)'`;;
	-k?*)	VMUNIX=`expr "${i}" : '-.\(.*\)'`;;
	-d?*)	ROOT=`expr "${i}" : '-.\(.*\)'`;;
	-local)	SRC=;;
	*)	echo "${CMD}:${i}:unknown option ${USAGE}" >&2
		exit 1;;
	esac
done

# /etc/services, /etc/protocols, and /etc/disktab are data files that
# may not have had the newest versions installed yet
DATAFILES=
for i in /etc/disktab /etc/protocols /etc/services
do
	if [ ! -f ${ROOT}${SRC}/${i} ]
	then DATAFILES="${DATAFILES} ${ROOT}${i}"
	else DATAFILES="${DATAFILES} ${ROOT}${SRC}/${i}"
	fi
done

echo "${CMD}: checking if all required files exist....." >&2
# /etc/group, /etc/passwd, and /etc/hosts datafiles are stripped.
if [ ! -f ${ROOT}${SRC}/etc/group ]
then
	GROUP=/etc/group
	echo "${CMD}: warning!:using local /etc/group" >&2
else
	GROUP=${ROOT}${SRC}/etc/group
fi

if [ ! -f ${ROOT}${SRC}/etc/passwd ]
then
	PASSWD=/etc/passwd
	echo "${CMD}: warning!:using local /etc/passwd" >&2
else
	PASSWD=${ROOT}${SRC}/etc/passwd
fi

if [ ! -f ${ROOT}${SRC}/etc/hosts ]
then
	HOSTS=/etc/hosts
	echo "${CMD}: warning!:using local /etc/hosts" >&2
else
	HOSTS=${ROOT}${SRC}/etc/hosts
fi

if [ ! -f ${ROOT}${SRC}/dev/MAKEDEV ]
then MAKEDEV=/dev/MAKEDEV
else MAKEDEV=${ROOT}${SRC}/dev/MAKEDEV
fi

BOOT=${ROOT}/usr/mdec/bootfd
BOOTBLOCK=${ROOT}/usr/mdec/fd1.2mboot

# root directory
DIST=/sys/dist

# original /bin files
BIN="${ROOT}/bin/sh ${ROOT}/bin/dd ${ROOT}/bin/expr ${ROOT}/bin/test"

# local /bin files
LOCALBIN="${DIST}/bin/sync.sh ${DIST}/bin/cat.sh ${DIST}/bin/mkdir.sh \
	${DIST}/bin/chmod.sh ${DIST}/bin/echo.sh \
	${DIST}/bin/ln.sh ${DIST}/bin/ls.sh ${DIST}/bin/df.sh \
	${DIST}/bin/rmdir.sh ${DIST}/bin/date.sh ${DIST}/bin/kill.sh"

# orginal /etc files
# ETC="${ROOT}/sbin/fsck ${ROOT}/sbin/restore ${ROOT}/sbin/routed"

# /sbin files
SBIN="${ROOT}/sbin/restore ${ROOT}/sbin/newfs ${ROOT}/sbin/mount"

# local /sbin files
LOCALSBIN="${DIST}/sbin/dtype ${DIST}/sbin/init"

# local /etc files
LOCALETC="${DIST}/etc/onechar ${DIST}/etc/fstab \
	${DIST}/etc/sizeck.sh ${DIST}/etc/whichdev.sh \
	${DIST}/etc/ask.sh ${DIST}/etc/yesno.sh \
	${DIST}/etc/rc.sh ${DIST}/etc/halt.sh ${DIST}/etc/reboot.sh \
	${DIST}/etc/umount.sh ${DIST}/etc/mask.sh \
	${DIST}/etc/mkconfig.sh ${DIST}/etc/syscall ${DIST}/etc/type.sh"

# local /lib files
LOCALLIB="${DIST}/lib/install.driver.sh ${DIST}/lib/install.mainmenu.sh \
	${DIST}/lib/install.options.sh ${DIST}/lib/install.welcome.sh"

# local /usr/bin files
LOCALUSRBIN="${DIST}/usr/bin/sleep.sh ${DIST}/usr/bin/basename.sh"

# local /usr/ucb files
LOCALUCB="${DIST}/usr/ucb/page.sh"

# original /usr/mdec files
MDEC="${ROOT}/usr/mdec/boothd ${ROOT}/usr/mdec/hd* ${ROOT}/usr/mdec/installboot"

# original /usr/ibm files
IBM="${ROOT}/usr/ibm/ftc"

MISSING=
for i in ${VMUNIX} ${DEVICE} ${BOOT} ${BOOTBLOCK} ${DATAFILES} ${GROUP} ${PASSWD} \
        ${HOSTS} ${MAKEDEV} ${BIN} ${LOCALBIN} ${ETC} ${LOCALETC} ${LOCALLIB} \
        ${LOCALUSRBIN} ${LOCALUCB} ${MDEC} ${IBM}
do
	test -f ${i} || MISSING="${MISSING} ${i}"
done

if [ "${MISSING}" ]
then
	echo "${CMD}: cannot find" ${MISSING} >&2
	exit 1
fi

if [ `whoami` != root ]
then
	echo "${CMD}: can only be run by root" >&2
	exit 1
fi

case "${DEVICE}" in
/dev/fd[01])
	# format diskette (fdformat will ask before formatting)
	RDEVICE=`echo ${DEVICE} | sed s'@@fd@@rfd@@'`
	fdformat -h ${RDEVICE};;
esac

# make a bootable file system
while : rebuild filesystem?
do
    echo -n "${CMD}: rebuild filesystem on" ${DEVICE} " [yn]?">&2
    read answer
    case $answer in
    	"n")	break;;

    	"y")	${ROOT}/usr/mdec/installboot ${BOOTBLOCK} ${BOOT} ${DEVICE}
		${ROOT}/sbin/newfs ${DEVICE} 
		${ROOT}/sbin/tunefs -m 0 -o space ${DEVICE} 
		break;;

    	*)	echo "Please answer 'y' or 'n'" >&2
    esac
done

echo "${CMD}: checking for a valid filesystem on" ${DEVICE} >&2
if ${ROOT}/sbin/fsck -n ${RDEVICE}
then : all is well
else
	echo "${CMD}: fsck ${RDEVICE} failed" >&2
	exit 1
fi

trap 'EXIT=${?}; cd /; umount ${DEVICE} > /dev/null 2>&1; exit ${EXIT}' 0 1 2 15

# create the temporary build directory
if [ -d ${TBUILD} ]; then
while : remove build tree?
do
    echo -n "${CMD}: the" ${TBUILD} "build directory exist.  Remove it?">&2
    read answer
    case $answer in
    	"n")	break;;

    	"y")	rm -rf ${TBUILD} || exit ${?}
		break;;

    	*)	echo "Please answer 'y' or 'n'" >&2
		continue;;
    esac
done
fi

if mkdir ${TBUILD}
then : all is well
else
	echo "${CMD}: can't create ${TBUILD}" >&2
	exit 1
fi

echo "${CMD}: making build tree in ${TBUILD}......" >&2

# set up the directories; make the device special files
cd ${TBUILD}
chmod 775 .
chgrp staff .
mkdir bin etc sbin dev lib mnt mnt/site tmp usr usr/bin usr/ucb usr/mdec usr/ibm
cd dev
sh -${-} ${MAKEDEV} std st0 fd0 hd0 hd1 hd2 sc0 sc1
cd ..

# install kernel binary, use ${TBUILD} to make install happy
install -c -s ${VMUNIX} ${TBUILD}/vmunix || exit ${?}
ln vmunix boot || exit ${?}

# set up the bin, sbin, etc, usr/bin, usr/ucb, and usr/mdec directories
for i in ${BIN}
do
	install -c ${i} bin/`basename ${i}` || exit ${?}
done
for i in ${LOCALBIN}
do
	install -c ${i} bin/`basename ${i} .sh` || exit ${?}
done

for i in ${SBIN}
do
	j=`basename ${i}`
	install -c ${i} sbin/$j || exit ${?}
done
for i in ${LOCALSBIN}
do
	j=`basename ${i} .sh`
	install -c ${i} sbin/$j || exit ${?}
done
ln sbin/newfs sbin/mfs || exit ${?}

for i in ${LOCALETC}
do
	j=`basename ${i} .sh`
	install -c ${i} etc/$j || exit ${?}
	ln etc/$j sbin/$j
done

for i in ${DATAFILES}
do
	sed '/^#/d' ${i} > etc/`basename ${i} .sh` || exit ${?}
done

# use whatever hosts file we found above
egrep -v '^#' ${HOSTS}			> etc/hosts || exit ${?}

# create minimal /etc/group and /etc/passwd
egrep '^wheel:|^staff:'	${GROUP}	> etc/group || exit ${?}
egrep '^root:'		${PASSWD}	> etc/passwd || exit ${?}

for i in ${LOCALUSRBIN}
do
	install -c ${i} usr/bin/`basename ${i} .sh` || exit ${?}
done

for i in ${LOCALUCB}
do
	install -c ${i} usr/ucb/`basename ${i} .sh` || exit ${?}
done

for i in ${MDEC}
do
	install -c ${i} usr/mdec/`basename ${i}` || exit ${?}
done

for i in ${IBM}
do
	install -c ${i} usr/ibm/`basename ${i}` || exit ${?}
done

for i in ${LOCALLIB}
do
	install -c ${i} lib/`basename ${i} .sh` || exit ${?}
done

install -c ${DIST}/restore.tape.sh ${TBUILD}/restore.tape || exit ${?}
install -c ${DIST}/xconf.sh ${TBUILD}/xconf || exit ${?}
#ln restore.tape restore.net || exit ${?}

tsize=`du -ks ${TBUILD} | awk '{ print $1}'`
maxsize=1049
if [ $tsize -gt $maxsize ]; then
	echo "${CMD}: build tree is" $tsize "KB which is larger than $maxsize KB" >&2
	exit
else
	echo "${CMD}: copying build tree (" $tsize "KB)......" >&2
fi

cd /
mount ${DEVICE} ${FS} || exit ${?}
rmdir ${FS}/lost+found 2>/dev/null
cd ${TBUILD}
find . -depth -print | cpio -pdlmv ${FS} || exit ${?}
sync; sync
cd /
df ${DEVICE}
umount ${DEVICE}
if fsck -n ${RDEVICE}
then : fsck succeeded
	echo "${CMD}: completed successfully" >&2
else
	echo "${CMD}: fsck ${RDEVICE} failed" >&2
	exit 1
fi
@


1.5
log
@update the default kernel image to be GENERIC.rtminiroot as used in the
Makefile.
@
text
@d2 1
a2 1
# $Header: /sys/rtdist/RCS/miniroot,v 1.4 1992/12/10 13:06:32 md Exp md $
d4 1
a4 1
# $Source: /sys/rtdist/RCS/miniroot,v $
d305 4
a308 2
if [ $tsize -gt 1043 ]; then
	echo "${CMD}: build tree is" $tsize "KB which larger than 1043Kb" >&2
d310 1
a310 1
	echo "${CMD}: copying build tree (" $tsize "Kb)......" >&2
a311 2

#exit
@


1.4
log
@little bit if cleaning up to get things right.
@
text
@d2 1
a2 1
# $Header: /usr/src/sys/rtdist/RCS/miniroot,v 1.3 1992/11/27 13:49:38 md Exp md $
d4 1
a4 1
# $Source: /usr/src/sys/rtdist/RCS/miniroot,v $
d21 1
a21 1
	-k<file>	kernel binary to use	[/sys/MINIROOT/vmunix]
d32 1
a32 1
VMUNIX=/sys/MINIROOT/vmunix
@


1.3
log
@many changes, mainly to build disk image in /tmp first so we can check
that we don't exceed the size of of the floppy.
@
text
@d2 1
a2 1
# $Header: /usr/src/sys/dist/RCS/mkMINIROOT,v 1.3 1992/11/27 13:49:52 md Exp $
d4 1
a4 1
# $Source: /usr/src/sys/dist/RCS/mkMINIROOT,v $
d34 1
a34 1
ROOT=/
d170 1
a170 1
    echo -n "${CMD}: rebuild filesystem on" ${DEVICE} "?">&2
a180 1
		continue;;
d268 2
a269 8
# /etc/hosts -> /tmp/hosts -> /etc/hosts.base
# /etc/hosts.base is a minimal /etc/hosts
# when /tmp is mounted on a writable file system,
#	/etc/hosts.base is copied to /etc/hosts -> /tmp/hosts,
#	and we have a writable /etc/hosts
ln -s /tmp/hosts etc/hosts || exit ${?}
ln -s /etc/hosts.base tmp/hosts || exit ${?}
egrep -v '^#' ${HOSTS}			> etc/hosts.base || exit ${?}
@


1.2
log
@reno mods
@
text
@d2 1
a2 1
# $Header:miniroot 12.2$
d4 1
a4 1
# $Source: /ibm/acis/usr/sys/dist/RCS/miniroot,v $
d26 2
a27 4
# uses Makefile to make the "local" (miniroot specific) utilities
# if the string ATR is found in the name of the kernel binary,
#	an ATR miniroot is created
# unless local is specified, tries to use /usr/src versions of datafiles
d30 1
d35 1
d61 1
d66 1
a66 1
	echo "${CMD}:warning!:using local /etc/group" >&2
d74 1
a74 1
	echo "${CMD}:warning!:using local /etc/passwd" >&2
d82 1
a82 1
	echo "${CMD}:warning!:using local /etc/hosts" >&2
d92 2
a93 8
case "${VMUNIX}" in
*ATR*)	ATR=true
	BOOT=
	BOOTBLOCK=;;
*)	ATR=false
	BOOT=${ROOT}/usr/mdec/bootfd
	BOOTBLOCK=${ROOT}/usr/mdec/fd1.2mboot;;
esac
d99 1
a99 1
BIN="${ROOT}/bin/sh"
d103 1
a103 1
	${DIST}/bin/chmod.sh ${DIST}/bin/echo.sh ${DIST}/bin/test.sh \
d109 3
a111 1
ETC="${ROOT}/sbin/fsck ${ROOT}/sbin/restore"
d113 3
d117 5
a121 4
LOCALETC="${DIST}/etc/onechar \
	${DIST}/etc/newfs ${DIST}/etc/sizeck.sh ${DIST}/etc/whichdev.sh \
	${DIST}/etc/init.sh ${DIST}/etc/halt.sh ${DIST}/etc/reboot.sh \
	${DIST}/etc/mount.sh ${DIST}/etc/umount.sh ${DIST}/etc/mask.sh \
d132 1
a132 1
LOCALUCB="${DIST}/usr/ucb/page.sh ${DIST}/usr/ucb/rsh"
d150 1
a150 1
	echo "${CMD}:cannot find" ${MISSING} >&2
d156 1
a156 1
	echo "${CMD}:can only be run by root" >&2
d168 11
a178 4
if ${ATR}
then
	# zero the device
	../dist_atr/writeinstall -z -l${SIZE} ${DEVICE}
d180 4
a183 5
	case "${DEVICE}" in
	/dev/fd[01])
		# install proper header via a doswrite
		doswrite -i -v -f ${DEVICE};;
	esac
d185 3
a187 1
	${ROOT}/etc/mkfs ${DEVICE} 2880 18 2 4096 512 32 0 6 4096 s
d189 22
a210 3
	${ROOT}/usr/mdec/installboot ${BOOTBLOCK} ${BOOT} ${DEVICE}
#	${ROOT}/etc/mkfs ${DEVICE} 2367 15 2 4096 512 32 0 6 2048 s
	${ROOT}/sbin/newfs ${DEVICE} 
d213 1
a213 1
if ${ROOT}/sbin/fsck -n ${DEVICE}
d216 1
a216 1
	echo "${CMD}:fsck ${DEVICE} failed" >&2
d220 1
a220 2
trap 'EXIT=${?}; cd /; umount ${DEVICE} > /dev/null 2>&1; exit ${EXIT}' 0 1 2 15
mount ${DEVICE} ${FS} || exit ${?}
d223 1
a223 2
cd ${FS}
rmdir lost+found
d231 2
a232 2
# install kernel binary, use ${FS} to make install happy
install -c -s ${VMUNIX} ${FS}/vmunix || exit ${?}
d235 1
a235 7
# the miniroot uses this link to distinguish between ATR & RT
if ${ATR}
then
	ln vmunix vmunix.atr
fi

# set up the bin, etc, usr/bin, usr/ucb, and usr/mdec directories
d245 1
a245 4
# RENO expects executibles in /sbin, not /etc (most important: init)
# until we check all scripts for references to /etc, hack in a link.
# note: hardlink uses less space than softlink.
for i in ${ETC}
d248 6
a253 2
	install -c ${i} etc/$j || exit ${?}
	ln etc/$j sbin/$j
d255 2
a263 4
# /etc/newfs, and /etc/ifconfig are merged on miniroot
ln etc/newfs etc/ifconfig || exit ${?}
ln etc/newfs etc/mfs || exit ${?}

d307 12
a318 2
install -c ${DIST}/restore.tape.sh ${FS}/restore.tape || exit ${?}
ln restore.tape restore.net || exit ${?}
d320 5
d329 1
a329 1
if fsck -n ${DEVICE}
d331 1
d333 1
a333 1
	echo "${CMD}:fsck ${DEVICE} failed" >&2
@


1.1
log
@Initial revision
@
text
@d12 1
a12 1
PATH=/etc:/usr/ucb:/bin:/usr/bin:/usr/ibm
d113 2
a114 1
ETC="${ROOT}/etc/fsck ${ROOT}/etc/restore ${ROOT}/etc/routed"
d118 1
a118 1
	${DIST}/etc/mkfs ${DIST}/etc/sizeck.sh ${DIST}/etc/whichdev.sh \
d181 2
a182 1
	${ROOT}/etc/mkfs ${DEVICE} 2367 15 2 4096 512 32 0 6 2048 s
d185 1
a185 1
if ${ROOT}/etc/fsck -n ${DEVICE}
d200 1
a200 1
mkdir bin etc dev lib mnt mnt/site tmp usr usr/bin usr/ucb usr/mdec usr/ibm
d218 1
a218 1
	install -c -s ${i} bin/`basename ${i}` || exit ${?}
d225 3
d230 3
a232 1
	install -c -s ${i} etc/`basename ${i}` || exit ${?}
d236 3
a238 1
	install -c -s ${i} etc/`basename ${i} .sh` || exit ${?}
d241 3
a243 3
# /etc/mkfs, /etc/newfs, and /etc/ifconfig are merged on miniroot
ln etc/mkfs etc/newfs || exit ${?}
ln etc/mkfs etc/ifconfig || exit ${?}
d270 1
a270 1
	install -c -s ${i} usr/ucb/`basename ${i} .sh` || exit ${?}
d280 1
a280 1
	install -c -s ${i} usr/ibm/`basename ${i}` || exit ${?}
d293 1
a300 1
df ${DEVICE}
@
