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