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