summaryrefslogtreecommitdiff
path: root/distrib/sparc/ramdisk/dot.profile
blob: 2ead5d263fe269e9e351f74fe0b1c7ce6849e71c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# $NetBSD: dot.profile,v 1.20 2009/12/24 14:56:14 tsutsui Exp $
#
# Copyright (c) 2000 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Paul Kranenburg.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

PATH=/sbin:/bin:/usr/bin:/usr/sbin:/
export PATH
HOME=/
export HOME

umask 022

MACHINE=sparc
INSTFS_MP=/instfs
MINIROOT_FSSIZE=10000
MINIROOT_BPINODE=1024

if [ "${BOOTFS_DONEPROFILE}" != "YES" ]; then

	BOOTFS_DONEPROFILE=YES
	export BOOTFS_DONEPROFILE

	# mount root read-write
	mount_ffs -o update /dev/md0a /

	# mount /instfs
	mount_mfs -s $MINIROOT_FSSIZE -i $MINIROOT_BPINODE swap $INSTFS_MP
fi

# A cat simulator
cat()
{
	local l
	while read l; do
		echo "$l"
	done
}

_resp=""
getresp() {
	read _resp
	if [ "$_resp" = "" ]; then
		_resp=$1
	fi
}

# Load instfs

floppy()
{
	local dev rval

	rval=0
	dev="/dev/fd0a"

	echo "Ejecting floppy disk"
	eject $dev

	cat <<EOF
Remove the boot disk from the floppy station and insert the second disk of
the floppy installation set into the disk drive.

The question below allows you to specify the device name of the floppy
drive.  Usually, the default device will do just fine.
EOF
	echo -n "Floppy device to load the installation utilities from [$dev]: "
	getresp "$dev"; dev="$_resp"

	echo "Extracting installation utilities... "
	(cd $INSTFS_MP && tar zxpf $dev) || rval=1

	echo "Ejecting floppy disk"
	eject $dev
	return $rval
}

tape()
{
	local dev fn bsa
	cat <<EOF
By default, the installation utilities are located in the second tape file
on the NetBSD/sparc installation tape. In case your tape layout is different,
choose the appropriate tape file number below.

EOF
	dev="/dev/nrst0"
	echo -n "Tape device to load the installation utilities from [$dev]: "
	getresp "$dev"; dev="$_resp"

	fn=2
	echo -n "Tape file number [$fn]: "
	getresp "$fn"; fn="$_resp"

	echo -n "Tape block size (use only if you know you need it): "
	getresp ""; if [ "$_resp" != "" ]; then
		bsa="-b $_resp"
	fi

	echo "Positioning tape... "
	mt -f $dev asf $(($fn - 1))
	[ $? = 0 ] || return 1

	echo "Extracting installation utilities... "
	(cd $INSTFS_MP && tar $bsa -z -x -p -f $dev) || return 1
}

cdrom()
{
	local dev tf rval
	cat <<EOF
The installation utilities are located on the ISO CD9660 filesystem on the
NetBSD/sparc CD-ROM. We need to mount the filesystem from the CD-ROM device
which you can specify below. Note: after the installation utilities are
extracted this filesystem will be unmounted again.

EOF

	rval=0
	dev="/dev/cd0a"
	echo -n "CD-ROM device to use [$dev]: "
	getresp "$dev"; dev="$_resp"

	mount_cd9660 -o rdonly $dev /cdrom || return 1

	# Look for instfs.tgz in MACHINE subdirectory first
	tf=/cdrom/$MACHINE/installation/bootfs/instfs.tgz
	[ -f $tf ] || tf=/cdrom/installation/bootfs/instfs.tgz
	[ -f $tf ] || {
		echo "Note: instfs.tgz image not found in default location"
		tf=""
	}

	while :; do
		echo -n "Path to instfs.tgz [$tf] "
		[ -z "$tf" ] && echo -n "(<return> to abort) "
		getresp "$tf"; tf="$_resp"
		[ -z "$tf" ] && { rval=1; break; }
		[ -f "$tf" ] && break;
		echo "$tf not found"
		tf=""
	done

	[ $rval = 0 ] && (cd $INSTFS_MP && tar zxpf $tf) || rval=1

	umount /cdrom
	return $rval
}

cat <<EOF
Welcome to the NetBSD/sparc microroot setup utility.

We've just completed the first stage of a two-stage procedure to load a
fully functional NetBSD installation environment on your machine.  In the
second stage which is to follow now, a set of additional installation
utilities must be load from your NetBSD/sparc installation medium.

EOF

while :; do
	cat <<EOF
This procedure supports one of the following media:

	1) cdrom
	2) tape
	3) floppy

EOF
	echo -n "Installation medium to load the additional utilities from: "
	read answer
	echo ""
	case "$answer" in
		1|cdrom)	_func=cdrom;;
		2|tape)		_func=tape;;
		3|floppy)	_func=floppy;;
		*)		echo "option not supported"; continue;;
	esac
	$_func && break
done

# switch to /instfs, and pretend we logged in there.
chroot $INSTFS_MP /bin/sh /.profile

#
echo "Back in microroot; halting machine..."
halt