1# $NetBSD: dot.profile,v 1.17 2002/07/20 07:06:28 lukem 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 38PATH=/sbin:/bin:/usr/bin:/usr/sbin:/ 39export PATH 40HOME=/ 41export HOME 42 43umask 022 44 45MACHINE=sparc 46INSTFS_MP=/instfs 47MINIROOT_FSSIZE=10000 48MINIROOT_BPINODE=1024 49 50if [ "${BOOTFS_DONEPROFILE}" != "YES" ]; then 51 52 BOOTFS_DONEPROFILE=YES 53 export BOOTFS_DONEPROFILE 54 55 # mount root read-write 56 mount_ffs -o update /dev/md0a / 57 58 # mount /instfs 59 mount_mfs -s $MINIROOT_FSSIZE -i $MINIROOT_BPINODE swap $INSTFS_MP 60fi 61 62# A cat simulator 63cat() 64{ 65 local l 66 while read l; do 67 echo "$l" 68 done 69} 70 71_resp="" 72getresp() { 73 read _resp 74 if [ "$_resp" = "" ]; then 75 _resp=$1 76 fi 77} 78 79# Load instfs 80 81floppy() 82{ 83 local dev rval 84 85 rval=0 86 87 echo "Ejecting floppy disk" 88 eject floppy 89 90 cat <<EOF 91Remove the boot disk from the floppy station and insert the second disk of 92the floppy installation set into the disk drive. 93 94The question below allows you to specify the device name of the floppy 95drive. Usually, the default device will do just fine. 96EOF 97 dev="/dev/rfd0a" 98 echo -n "Floppy device to load the installation utilities from [$dev]: " 99 getresp "$dev"; dev="$_resp" 100 101 echo "Extracting installation utilities... " 102 (cd $INSTFS_MP && tar zxpf $dev) || rval=1 103 104 echo "Ejecting floppy disk" 105 eject floppy 106 return $rval 107} 108 109tape() 110{ 111 local dev fn bsa 112 cat <<EOF 113By default, the installation utilities are located in the second tape file 114on the NetBSD/sparc installation tape. In case your tape layout is different, 115choose the appropriate tape file number below. 116 117EOF 118 dev="/dev/nrst0" 119 echo -n "Tape device to load the installation utilities from [$dev]: " 120 getresp "$dev"; dev="$_resp" 121 122 fn=2 123 echo -n "Tape file number [$fn]: " 124 getresp "$fn"; fn="$_resp" 125 126 echo -n "Tape block size (use only if you know you need it): " 127 getresp ""; if [ "$_resp" != "" ]; then 128 bsa="-b $_resp" 129 fi 130 131 echo "Positioning tape... " 132 mt -f $dev asf $(($fn - 1)) 133 [ $? = 0 ] || return 1 134 135 echo "Extracting installation utilities... " 136 (cd $INSTFS_MP && tar $bsa -z -x -p -f $dev) || return 1 137} 138 139cdrom() 140{ 141 local dev tf rval 142 cat <<EOF 143The installation utilities are located on the ISO CD9660 filesystem on the 144NetBSD/sparc CD-ROM. We need to mount the filesystem from the CD-ROM device 145which you can specify below. Note: after the installation utilities are 146extracted this filesystem will be unmounted again. 147 148EOF 149 150 rval=0 151 dev="/dev/cd0a" 152 echo -n "CD-ROM device to use [$dev]: " 153 getresp "$dev"; dev="$_resp" 154 155 mount_cd9660 -o rdonly $dev /cdrom || return 1 156 157 # Look for instfs.tgz in MACHINE subdirectory first 158 tf=/cdrom/$MACHINE/installation/bootfs/instfs.tgz 159 [ -f $tf ] || tf=/cdrom/installation/bootfs/instfs.tgz 160 [ -f $tf ] || { 161 echo "Note: instfs.tgz image not found in default location" 162 tf="" 163 } 164 165 while :; do 166 echo -n "Path to instfs.tgz [$tf] " 167 [ -z "$tf" ] && echo -n "(<return> to abort) " 168 getresp "$tf"; tf="$_resp" 169 [ -z "$tf" ] && { rval=1; break; } 170 [ -f "$tf" ] && break; 171 echo "$tf not found" 172 tf="" 173 done 174 175 [ $rval = 0 ] && (cd $INSTFS_MP && tar zxpf $tf) || rval=1 176 177 umount /cdrom 178 return $rval 179} 180 181cat <<EOF 182Welcome to the NetBSD/sparc microroot setup utility. 183 184We've just completed the first stage of a two-stage procedure to load a 185fully functional NetBSD installation environment on your machine. In the 186second stage which is to follow now, a set of additional installation 187utilities must be load from your NetBSD/sparc installation medium. 188 189EOF 190 191while :; do 192 cat <<EOF 193This procedure supports one of the following media: 194 195 1) cdrom 196 2) tape 197 3) floppy 198 199EOF 200 echo -n "Installation medium to load the additional utilities from: " 201 read answer 202 echo "" 203 case "$answer" in 204 1|cdrom) _func=cdrom;; 205 2|tape) _func=tape;; 206 3|floppy) _func=floppy;; 207 *) echo "option not supported"; continue;; 208 esac 209 $_func && break 210done 211 212# switch to /instfs, and pretend we logged in there. 213chroot $INSTFS_MP /bin/sh /.profile 214 215# 216echo "Back in microroot; halting machine..." 217halt 218