Home | History | Annotate | Line # | Download | only in ramdisk
dot.profile revision 1.16
      1 # $NetBSD: dot.profile,v 1.16 2001/06/17 11:57:23 pk Exp $
      2 #
      3 # Copyright (c) 2000 The NetBSD Foundation, Inc.
      4 # All rights reserved.
      5 #
      6 # This code is derived from software contributed to The NetBSD Foundation
      7 # by Paul Kranenburg.
      8 #
      9 # Redistribution and use in source and binary forms, with or without
     10 # modification, are permitted provided that the following conditions
     11 # are met:
     12 # 1. Redistributions of source code must retain the above copyright
     13 #    notice, this list of conditions and the following disclaimer.
     14 # 2. Redistributions in binary form must reproduce the above copyright
     15 #    notice, this list of conditions and the following disclaimer in the
     16 #    documentation and/or other materials provided with the distribution.
     17 # 3. All advertising materials mentioning features or use of this software
     18 #    must display the following acknowledgement:
     19 #        This product includes software developed by the NetBSD
     20 #        Foundation, Inc. and its contributors.
     21 # 4. Neither the name of The NetBSD Foundation nor the names of its
     22 #    contributors may be used to endorse or promote products derived
     23 #    from this software without specific prior written permission.
     24 #
     25 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     26 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     29 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35 # POSSIBILITY OF SUCH DAMAGE.
     36 #
     37 
     38 PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
     39 export PATH
     40 HOME=/
     41 export HOME
     42 
     43 umask 022
     44 
     45 MACHINE=sparc
     46 INSTFS_MP=/instfs
     47 MINIROOT_FSSIZE=10000
     48 
     49 if [ "${BOOTFS_DONEPROFILE}" != "YES" ]; then
     50 
     51 	BOOTFS_DONEPROFILE=YES
     52 	export BOOTFS_DONEPROFILE
     53 
     54 	# mount root read-write
     55 	mount_ffs -o update /dev/md0a /
     56 
     57 	# mount /instfs
     58 	mount_mfs -s $MINIROOT_FSSIZE swap $INSTFS_MP
     59 fi
     60 
     61 # A cat simulator
     62 cat()
     63 {
     64 	local l
     65 	while read l; do
     66 		echo "$l"
     67 	done
     68 }
     69 
     70 _resp=""
     71 getresp() {
     72 	read _resp
     73 	if [ "$_resp" = "" ]; then
     74 		_resp=$1
     75 	fi
     76 }
     77 
     78 # Load instfs
     79 
     80 floppy()
     81 {
     82 	local dev rval
     83 
     84 	rval=0
     85 
     86 	echo "Ejecting floppy disk"
     87 	eject floppy
     88 
     89 	cat <<EOF
     90 Remove the boot disk from the floppy station and insert the second disk of
     91 the floppy installation set into the disk drive.
     92 
     93 The question below allows you to specify the device name of the floppy
     94 drive.  Usually, the default device will do just fine.
     95 EOF
     96 	dev="/dev/rfd0a"
     97 	echo -n "Floppy device to load the installation utilities from [$dev]: "
     98 	getresp "$dev"; dev="$_resp"
     99 
    100 	echo "Extracting installation utilities... "
    101 	(cd $INSTFS_MP && tar zxpf $dev) || rval=1
    102 
    103 	echo "Ejecting floppy disk"
    104 	eject floppy
    105 	return $rval
    106 }
    107 
    108 tape()
    109 {
    110 	local dev fn bsa
    111 	cat <<EOF
    112 By default, the installation utilities are located in the second tape file
    113 on the NetBSD/sparc installation tape. In case your tape layout is different,
    114 choose the appropriate tape file number below.
    115 
    116 EOF
    117 	dev="/dev/nrst0"
    118 	echo -n "Tape device to load the installation utilities from [$dev]: "
    119 	getresp "$dev"; dev="$_resp"
    120 
    121 	fn=2
    122 	echo -n "Tape file number [$fn]: "
    123 	getresp "$fn"; fn="$_resp"
    124 
    125 	echo -n "Tape block size (use only if you know you need it): "
    126 	getresp ""; if [ "$_resp" != "" ]; then
    127 		bsa="-b $_resp"
    128 	fi
    129 
    130 	echo "Positioning tape... "
    131 	mt -f $dev asf $(($fn - 1))
    132 	[ $? = 0 ] || return 1
    133 
    134 	echo "Extracting installation utilities... "
    135 	(cd $INSTFS_MP && tar $bsa -z -x -p -f $dev) || return 1
    136 }
    137 
    138 cdrom()
    139 {
    140 	local dev tf rval
    141 	cat <<EOF
    142 The installation utilities are located on the ISO CD9660 filesystem on the
    143 NetBSD/sparc CD-ROM. We need to mount the filesystem from the CD-ROM device
    144 which you can specify below. Note: after the installation utilities are
    145 extracted this filesystem will be unmounted again.
    146 
    147 EOF
    148 
    149 	rval=0
    150 	dev="/dev/cd0a"
    151 	echo -n "CD-ROM device to use [$dev]: "
    152 	getresp "$dev"; dev="$_resp"
    153 
    154 	mount_cd9660 -o rdonly $dev /cdrom || return 1
    155 
    156 	# Look for instfs.tgz in MACHINE subdirectory first
    157 	tf=/cdrom/$MACHINE/installation/bootfs/instfs.tgz
    158 	[ -f $tf ] || tf=/cdrom/installation/bootfs/instfs.tgz
    159 	[ -f $tf ] || {
    160 		echo "Note: instfs.tgz image not found in default location"
    161 		tf=""
    162 	}
    163 
    164 	while :; do
    165 		echo -n "Path to instfs.tgz [$tf] "
    166 		[ -z "$tf" ] && echo -n "(<return> to abort) "
    167 		getresp "$tf"; tf="$_resp"
    168 		[ -z "$tf" ] && { rval=1; break; }
    169 		[ -f "$tf" ] && break;
    170 		echo "$tf not found"
    171 		tf=""
    172 	done
    173 
    174 	[ $rval = 0 ] && (cd $INSTFS_MP && tar zxpf $tf) || rval=1
    175 
    176 	umount /cdrom
    177 	return $rval
    178 }
    179 
    180 cat <<EOF
    181 Welcome to the NetBSD/sparc microroot setup utility.
    182 
    183 We've just completed the first stage of a two-stage procedure to load a
    184 fully functional NetBSD installation environment on your machine.  In the
    185 second stage which is to follow now, a set of additional installation
    186 utilities must be load from your NetBSD/sparc installation medium.
    187 
    188 EOF
    189 
    190 while :; do
    191 	cat <<EOF
    192 This procedure supports one of the following media:
    193 
    194 	1) cdrom
    195 	2) tape
    196 	3) floppy
    197 
    198 EOF
    199 	echo -n "Installation medium to load the additional utilities from: "
    200 	read answer
    201 	echo ""
    202 	case "$answer" in
    203 		1|cdrom)	_func=cdrom;;
    204 		2|tape)		_func=tape;;
    205 		3|floppy)	_func=floppy;;
    206 		*)		echo "option not supported"; continue;;
    207 	esac
    208 	$_func && break
    209 done
    210 
    211 # switch to /instfs, and pretend we logged in there.
    212 chroot $INSTFS_MP /bin/sh /.profile
    213 
    214 #
    215 echo "Back in microroot; halting machine..."
    216 halt
    217