1b70875b0Sbostic#!/bin/sh - 2cc418804Skarels# 301bb05e4Sbostic# Copyright (c) 1990 The Regents of the University of California. 4b70875b0Sbostic# All rights reserved. 5cc418804Skarels# 601bb05e4Sbostic# %sccs.include.redist.sh% 7cc418804Skarels# 8*949bdf46Skarels# @(#)get 1.8 (Berkeley) 05/21/91 9b70875b0Sbostic# 1001bb05e4Sbostic 11b70875b0Sbostic# Shell script to build a mini-root file system in preparation for building 12b70875b0Sbostic# a distribution tape. The file system created here is image copied onto 13b70875b0Sbostic# tape, then image copied onto disk as the "first" step in a cold boot of 14b70875b0Sbostic# 4.3BSD systems. 15cc418804Skarels# 16cc418804SkarelsDISTROOT=/nbsd 17cc418804Skarels# 18cc418804Skarelsif [ `pwd` = '/' ] 19cc418804Skarelsthen 20cc418804Skarels echo You just '(almost)' destroyed the root 21cc418804Skarels exit 22cc418804Skarelsfi 23b70875b0Sbostic 24b70875b0Sbostic# copy in kernel 2501bb05e4Sbosticcp $DISTROOT/sys/GENERIC.alltahoe/vmunix . 26b70875b0Sbostic 27b70875b0Sbostic# create necessary directories 2801bb05e4SbosticDIRLIST="bin dev etc a tmp stand sbin" 29b70875b0Sbosticrm -rf $DIRLIST 30b70875b0Sbosticmkdir $DIRLIST 31b70875b0Sbostic 3201bb05e4SbosticETC="disktab" 3301bb05e4Sbosticfor i in $ETC; do 34b70875b0Sbostic cp $DISTROOT/etc/$i etc/$i 35b70875b0Sbosticdone 36b70875b0Sbostic 3701bb05e4SbosticSBIN="disklabel fsck ifconfig init mknod mount newfs restore \ 3801bb05e4Sbostic rrestore umount" 3901bb05e4Sbosticfor i in $SBIN; do 4001bb05e4Sbostic cp $DISTROOT/sbin/$i sbin/$i 4101bb05e4Sbosticdone 4201bb05e4Sbostic 4301bb05e4SbosticBIN="[ cat cp dd echo ed expr ls mkdir mv rcp rm sh stty sync" 4401bb05e4SbosticUBIN="awk make mt" 4501bb05e4Sbosticfor i in $BIN; do 46b70875b0Sbostic cp $DISTROOT/bin/$i bin/$i 47b70875b0Sbosticdone 4801bb05e4Sbosticfor i in $UBIN; do 4901bb05e4Sbostic cp $DISTROOT/usr/bin/$i bin/$i 5001bb05e4Sbosticdone 51b70875b0Sbosticln bin/stty bin/STTY 52b70875b0Sbostic 5301bb05e4SbosticSTAND="copy vdformat" 5401bb05e4Sbosticfor i in $STAND; do 55b70875b0Sbostic cp $DISTROOT/stand/$i stand/$i 56b70875b0Sbosticdone 57b70875b0Sbostic 5801bb05e4SbosticDOT=".profile boot fppoc fppwcs poc poc1 poc2 wcs" 5901bb05e4Sbostic#DOT=".profile boot" 6001bb05e4Sbosticfor i in $DOT; do 61b70875b0Sbostic cp $DISTROOT/$i $i 62b70875b0Sbosticdone 63b70875b0Sbostic 64b70875b0Sbostic# initialize /dev 65b70875b0Sbosticcp $DISTROOT/dev/MAKEDEV dev/MAKEDEV 66b70875b0Sbosticchmod +x dev/MAKEDEV 67b70875b0Sbosticcp /dev/null dev/MAKEDEV.local 68*949bdf46Skarels(cd dev; ./MAKEDEV std hd0 hd1 dk0 dk1; ./MAKEDEV cy0; mv rmt12 cy0; rm *mt*) 69b70875b0Sbostic 70b70875b0Sbostic# initialize /etc/passwd 71cc418804Skarelscat >etc/passwd <<EOF 72cc418804Skarelsroot::0:10::/:/bin/sh 73cc418804SkarelsEOF 74b70875b0Sbostic 75b70875b0Sbostic# initialize /etc/group 76cc418804Skarelscat >etc/group <<EOF 77cc418804Skarelswheel:*:0: 78cc418804Skarelsstaff:*:10: 79cc418804SkarelsEOF 80b70875b0Sbostic 81b70875b0Sbostic# initialize /etc/fstab 82cc418804Skarelscat >etc/fstab <<EOF 83*949bdf46Skarels/dev/dk0a /a ufs xx 1 1 84*949bdf46Skarels/dev/hd0a /a ufs xx 1 1 85cc418804SkarelsEOF 86b70875b0Sbostic 87b70875b0Sbostic# create xtr script 88cc418804Skarelscat >xtr <<'EOF' 896a3c22e4Skarels#!/bin/sh -e 90*949bdf46Skarels: ${disk?'Usage: disk=xx0 tape=yy [type=zz] xtr'} 91*949bdf46Skarels: ${tape?'Usage: disk=xx0 tape=yy [type=zz] xtr'} 92cc418804Skarelsecho 'Build root file system' 93*949bdf46Skarelsnewfs ${disk}a ${type} 94cc418804Skarelssync 95cc418804Skarelsecho 'Check the file system' 96cc418804Skarelsfsck /dev/r${disk}a 97cc418804Skarelsmount /dev/${disk}a /a 98cc418804Skarelscd /a 99cc418804Skarelsecho 'Rewind tape' 100cc418804Skarelsmt -f /dev/${tape}0 rew 101cc418804Skarelsecho 'Restore the dump image of the root' 102cc418804Skarelsrestore rsf 3 /dev/${tape}0 103cc418804Skarelscd / 104cc418804Skarelssync 10501bb05e4Sbosticumount /a 106cc418804Skarelssync 107cc418804Skarelsfsck /dev/r${disk}a 108cc418804Skarelsecho 'Root filesystem extracted' 109cc418804SkarelsEOF 110b70875b0Sbostic 111b70875b0Sbostic# make xtr script executable 112cc418804Skarelschmod +x xtr 113b70875b0Sbostic 114cc418804Skarelssync 115