install.md revision 1.5 1 # $NetBSD: install.md,v 1.5 1997/10/31 04:41:47 mhitch Exp $
2 #
3 #
4 # Copyright (c) 1996 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 #
7 # This code is derived from software contributed to The NetBSD Foundation
8 # by Jason R. Thorpe.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
12 # are met:
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
18 # 3. All advertising materials mentioning features or use of this software
19 # must display the following acknowledgement:
20 # This product includes software developed by the NetBSD
21 # Foundation, Inc. and its contributors.
22 # 4. Neither the name of The NetBSD Foundation nor the names of its
23 # contributors may be used to endorse or promote products derived
24 # from this software without specific prior written permission.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 # POSSIBILITY OF SUCH DAMAGE.
37 #
38
39 #
40 # machine dependent section of installation/upgrade script.
41 #
42
43 # Machine-dependent install sets
44 MDSETS=""
45
46 md_set_term() {
47 if [ ! -z "$TERM" ]; then
48 return
49 fi
50 echo -n "Specify terminal type [vt220]: "
51 getresp "vt220"
52 TERM="$resp"
53 export TERM
54 }
55
56 __mount_kernfs() {
57 #
58 # Force kern_fs to be mounted
59 #
60 if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
61 mkdir /kern > /dev/null 2>&1
62 /sbin/mount_kernfs /kern /kern >/dev/null 2>&1
63 fi
64 }
65
66 md_makerootwritable() {
67 # Mount root rw for convenience of the tester ;-)
68 if [ ! -e /tmp/.root_writable ]; then
69 __mount_kernfs
70 # XXX: Use /kern/rootdev instead?
71 mount -u /kern/rootdev / > /dev/null 2>&1
72 cp /dev/null /tmp/.root_writable
73 fi
74 }
75
76 md_get_diskdevs() {
77 # return available disk devices
78 __mount_kernfs
79 sed -n -e '/^[sw]d[0-9] /s/ .*//p' \
80 < /kern/msgbuf | sort -u
81 }
82
83 md_get_cddevs() {
84 # return available CDROM devices
85 __mount_kernfs
86 sed -n -e '/^cd[0-9] /s/ .*//p' \
87 < /kern/msgbuf | sort -u
88 }
89
90 md_get_partition_range() {
91 # return an expression describing the valid partition id's
92 echo '[a-p]'
93 }
94
95 md_installboot() {
96 if [ -x /mnt/usr/mdec/installboot ]; then
97 echo -n "Should a boot block be installed? [y] "
98 getresp "y"
99 case "$resp" in
100 y*|Y*)
101 echo "Installing boot block..."
102 chroot /mnt /usr/mdec/installboot /usr/mdec/xxboot /dev/r${1}a
103 ;;
104 *)
105 echo "No bootblock installed..."
106 ;;
107 esac
108 elif [ "$MODE" = "install" ]; then
109 cat << \__md_installboot_1
110 There is no installboot program found on the installed filesystems. No boot
111 programs are installed.
112 __md_installboot_1
113 else
114 cat << \__md_installboot_2
115 There is no installboot program found on the upgraded filesystems. No boot
116 programs are installed.
117 __md_installboot_2
118 fi
119 }
120
121 md_native_fstype() {
122 echo "ados"
123 }
124
125 md_native_fsopts() {
126 echo "-ro"
127 }
128
129 #md_prep_disklabel()
130 #{
131 # # $1 is the root disk
132 # # Note that the first part of this function is just a *very* verbose
133 # # version of md_label_disk().
134 #
135 # cat << \__md_prep_disklabel_1
136 #You now have to prepare your root disk for the installation of NetBSD. This
137 #is further referred to as 'labeling' a disk.
138 #
139 #Hit the <return> key when you have read this...
140 #__md_prep_disklabel_1
141 # getresp ""
142 #
143 # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
144 # if [ $? -eq 0 ]; then
145 # cat << \__md_prep_disklabel_2
146 #The disk you wish to install on is partitioned with AHDI or an AHDI compatible
147 #program. You have to assign some partitions to NetBSD before NetBSD is able
148 #to use the disk. Change the 'id' of all partitions you want to use for NetBSD
149 #filesystems to 'NBD'. Change the 'id' of the partition you wish to use for swap
150 #to 'NBS' or 'SWP'.
151 #
152 #Hit the <return> key when you have read this...
153 #__md_prep_disklabel_2
154 # getresp ""
155 # edahdi /dev/r${1}c
156 # fi
157 #
158 # # display example
159 # cat << \__md_prep_disklabel_3
160 #Here is an example of what the partition information will look like once
161 #you have entered the disklabel editor. Disk partition sizes and offsets
162 #are in sector (most likely 512 bytes) units.
163 #
164 #[Example]
165 #partition start (c/t/s) nblks (c/t/s) type
166 #
167 # a (root) 0 (0/00/00) 31392 (109/00/00) 4.2BSD
168 # b (swap) 31392 (109/00/00) 73440 (255/00/00) swap
169 # c (disk) 0 (0/00/00) 1070496 (3717/00/00) unused
170 # d (user) 104832 (364/00/00) 30528 (106/00/00) 4.2BSD
171 # e (user) 135360 (470/00/00) 40896 (142/00/00) 4.2BSD
172 # f (user) 176256 (612/00/00) 92160 (320/00/00) 4.2BSD
173 # g (user) 268416 (932/00/00) 802080 (2785/00/00) 4.2BSD
174 #
175 #[End of example]
176 #
177 #Hit the <return> key when you have read this...
178 #
179 #__md_prep_disklabel_3
180 # getresp ""
181 # edlabel /dev/r${1}c
182 #
183 # cat << \__md_prep_disklabel_4
184 #
185 #You will now be given the opportunity to place disklabels on any additional
186 #disks on your system.
187 #__md_prep_disklabel_4
188 #
189 # _DKDEVS=`rmel ${1} ${_DKDEVS}`
190 # resp="X" # force at least one iteration
191 # while [ "X$resp" != X"done" ]; do
192 # labelmoredisks
193 # done
194 #}
195 #
196 #md_labeldisk() {
197 # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
198 # [ $? -eq 0 ] && edahdi /dev/r${1}c
199 # edlabel /dev/r${1}c
200 #}
201
202 md_prep_disklabel() {
203 }
204
205 md_labeldisk() {
206 }
207
208 md_welcome_banner() {
209 if [ "$MODE" = "install" ]; then
210 echo ""
211 echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
212 cat << \__welcome_banner_1
213
214 This program is designed to help you put NetBSD on your disk,
215 in a simple and rational way. You'll be asked several questions,
216 and it would probably be useful to have your disk's hardware
217 manual, the installation notes, and a calculator handy.
218 __welcome_banner_1
219
220 else
221 echo ""
222 echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
223 cat << \__welcome_banner_2
224
225 This program is designed to help you upgrade your NetBSD system in a
226 simple and rational way.
227
228 As a reminder, installing the `etc' binary set is NOT recommended.
229 Once the rest of your system has been upgraded, you should manually
230 merge any changes to files in the `etc' set into those files which
231 already exist on your system.
232 __welcome_banner_2
233 fi
234
235 cat << \__welcome_banner_3
236
237 As with anything which modifies your disk's contents, this
238 program can cause SIGNIFICANT data loss, and you are advised
239 to make sure your data is backed up before beginning the
240 installation process.
241
242 Default answers are displayed in brackets after the questions.
243 You can hit Control-C at any time to quit, but if you do so at a
244 prompt, you may have to hit return. Also, quitting in the middle of
245 installation may leave your system in an inconsistent state.
246
247 __welcome_banner_3
248 }
249
250 md_not_going_to_install() {
251 cat << \__not_going_to_install_1
252
253 OK, then. Enter `halt' at the prompt to halt the machine. Once the
254 machine has halted, power-cycle the system to load new boot code.
255
256 Note: If you wish to have another try. Just type '^D' at the prompt. After
257 a moment, the installer will restart itself.
258
259 __not_going_to_install_1
260 }
261
262 md_congrats() {
263 local what;
264 if [ "$MODE" = "install" ]; then
265 what="installed";
266 else
267 what="upgraded";
268 fi
269 cat << __congratulations_1
270
271 CONGRATULATIONS! You have successfully $what NetBSD!
272 To boot the installed system, enter halt at the command prompt. Once the
273 system has halted, reset the machine and boot from the disk.
274
275 Note: If you wish to have another try. Just type '^D' at the prompt. After
276 a moment, the installer will restart itself.
277
278 __congratulations_1
279 }
280
281 md_copy_kernel() {
282 # This is largely a copy of install_disk and install_from_mounted_fs()
283 # with some special frobbing.
284
285 local _directory
286 local _sets
287 local _filename
288 local _f
289
290 if [ -e /netbsd ]; then
291 echo -n "Copying kernel..."
292 cp -p /netbsd /mnt/netbsd
293 echo "done."
294 return
295 fi
296
297 cat << \__md_copy_kernel_1
298 Your installation set did not include a netbsd kernel on the installation
299 filesystem. You are now given the opportunity install it from either the
300 kernel-floppy from the distribution or another location on one of your disks.
301
302 The following disk devices are installed on your system; please select
303 the disk device containing the partition with the netbsd kernel:
304 __md_copy_kernel_1
305
306 _DKDEVS=`md_get_diskdevs`
307 echo "$_DKDEVS"
308 echo "fd0"
309 echo ""
310 _DKDEVS="$_DKDEVS fd0" # Might be on the kernel floppy!
311 echo -n "Which is the disk with the kernel? [abort] "
312
313 if mount_a_disk ; then
314 return # couldn't mount the disk
315 fi
316
317 # Get the directory where the file lives
318 resp="" # force one iteration
319 while [ "X${resp}" = X"" ]; do
320 echo "Enter the directory relative to the mount point that"
321 echo -n "contains the file. [${_directory}] "
322 getresp "${_directory}"
323 done
324 _directory=$resp
325
326 _sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
327 if [ -z "$_sets" ]; then
328 echo "There are no NetBSD kernels available in \"$1\""
329 umount -f /mnt2 > /dev/null 2>&1
330 return
331 fi
332 while : ; do
333 echo "The following kernels are available:"
334 echo ""
335
336 for _f in $_sets ; do
337 echo " $_f"
338 done
339 echo ""
340 set -- $_sets
341 echo -n "File name [$1]? "
342 getresp "$1"
343 _f=$resp
344 _filename="/mnt2/$_directory/$_f"
345
346 # Ensure file exists
347 if [ ! -f $_filename ]; then
348 echo "File $_filename does not exist. Check to make"
349 echo "sure you entered the information properly."
350 echo -n "Do you want to retry [y]? "
351 getresp "y"
352 if [ "$resp" = "n" ]; then
353 break
354 fi
355 continue
356 fi
357
358 # Copy the kernel
359 cp $_filename /mnt
360 break
361 done
362 umount -f /mnt2 > /dev/null 2>&1
363 }
364