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