install.md revision 1.1 1 # $NetBSD: install.md,v 1.1 1997/09/09 23:07:05 is 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 REGENTS OR CONTRIBUTORS BE
30 # 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 /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_ifdevs() {
91 # return available network devices
92 __mount_kernfs
93 sed -n -e '/^ie[0-9] /s/ .*//p' \
94 -e '/^le[0-9] /s/ .*//p' \
95 < /kern/msgbuf | sort -u
96 }
97
98 md_get_partition_range() {
99 # return an expression describing the valid partition id's
100 echo '[a-p]'
101 }
102
103 md_installboot() {
104 if [ -x /mnt/usr/mdec/installboot ]; then
105 echo -n "Should a boot block be installed? [y] "
106 getresp "y"
107 case "$resp" in
108 y*|Y*)
109 echo "Installing boot block..."
110 chroot /mnt /usr/mdec/installboot -v $1
111 ;;
112 *)
113 echo "No bootblock installed..."
114 ;;
115 esac
116 elif [ "$MODE" = "install" ]; then
117 cat << \__md_installboot_1
118 There is no installboot program found on the installed filesystems. No boot
119 programs are installed.
120 __md_installboot_1
121 else
122 cat << \__md_installboot_2
123 There is no installboot program found on the upgraded filesystems. No boot
124 programs are installed.
125 __md_installboot_2
126 fi
127 }
128
129 md_native_fstype() {
130 echo "ados"
131 }
132
133 md_native_fsopts() {
134 echo "-ro"
135 }
136
137 #md_prep_disklabel()
138 #{
139 # # $1 is the root disk
140 # # Note that the first part of this function is just a *very* verbose
141 # # version of md_label_disk().
142 #
143 # cat << \__md_prep_disklabel_1
144 #You now have to prepare your root disk for the installation of NetBSD. This
145 #is further referred to as 'labeling' a disk.
146 #
147 #Hit the <return> key when you have read this...
148 #__md_prep_disklabel_1
149 # getresp ""
150 #
151 # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
152 # if [ $? -eq 0 ]; then
153 # cat << \__md_prep_disklabel_2
154 #The disk you wish to install on is partitioned with AHDI or an AHDI compatible
155 #program. You have to assign some partitions to NetBSD before NetBSD is able
156 #to use the disk. Change the 'id' of all partitions you want to use for NetBSD
157 #filesystems to 'NBD'. Change the 'id' of the partition you wish to use for swap
158 #to 'NBS' or 'SWP'.
159 #
160 #Hit the <return> key when you have read this...
161 #__md_prep_disklabel_2
162 # getresp ""
163 # edahdi /dev/r${1}c
164 # fi
165 #
166 # # display example
167 # cat << \__md_prep_disklabel_3
168 #Here is an example of what the partition information will look like once
169 #you have entered the disklabel editor. Disk partition sizes and offsets
170 #are in sector (most likely 512 bytes) units.
171 #
172 #[Example]
173 #partition start (c/t/s) nblks (c/t/s) type
174 #
175 # a (root) 0 (0/00/00) 31392 (109/00/00) 4.2BSD
176 # b (swap) 31392 (109/00/00) 73440 (255/00/00) swap
177 # c (disk) 0 (0/00/00) 1070496 (3717/00/00) unused
178 # d (user) 104832 (364/00/00) 30528 (106/00/00) 4.2BSD
179 # e (user) 135360 (470/00/00) 40896 (142/00/00) 4.2BSD
180 # f (user) 176256 (612/00/00) 92160 (320/00/00) 4.2BSD
181 # g (user) 268416 (932/00/00) 802080 (2785/00/00) 4.2BSD
182 #
183 #[End of example]
184 #
185 #Hit the <return> key when you have read this...
186 #
187 #__md_prep_disklabel_3
188 # getresp ""
189 # edlabel /dev/r${1}c
190 #
191 # cat << \__md_prep_disklabel_4
192 #
193 #You will now be given the opportunity to place disklabels on any additional
194 #disks on your system.
195 #__md_prep_disklabel_4
196 #
197 # _DKDEVS=`rmel ${1} ${_DKDEVS}`
198 # resp="X" # force at least one iteration
199 # while [ "X$resp" != X"done" ]; do
200 # labelmoredisks
201 # done
202 #}
203 #
204 #md_labeldisk() {
205 # edahdi /dev/r${1}c < /dev/null > /dev/null 2>&1
206 # [ $? -eq 0 ] && edahdi /dev/r${1}c
207 # edlabel /dev/r${1}c
208 #}
209
210 md_prep_disklabel() {
211 }
212
213 md_labeldisk() {
214 }
215
216 md_welcome_banner() {
217 if [ "$MODE" = "install" ]; then
218 echo ""
219 echo "Welcome to the NetBSD/amiga ${VERSION} installation program."
220 cat << \__welcome_banner_1
221
222 This program is designed to help you put NetBSD on your disk,
223 in a simple and rational way. You'll be asked several questions,
224 and it would probably be useful to have your disk's hardware
225 manual, the installation notes, and a calculator handy.
226 __welcome_banner_1
227
228 else
229 echo ""
230 echo "Welcome to the NetBSD/amiga ${VERSION} upgrade program."
231 cat << \__welcome_banner_2
232
233 This program is designed to help you upgrade your NetBSD system in a
234 simple and rational way.
235
236 As a reminder, installing the `etc' binary set is NOT recommended.
237 Once the rest of your system has been upgraded, you should manually
238 merge any changes to files in the `etc' set into those files which
239 already exist on your system.
240 __welcome_banner_2
241 fi
242
243 cat << \__welcome_banner_3
244
245 As with anything which modifies your disk's contents, this
246 program can cause SIGNIFICANT data loss, and you are advised
247 to make sure your data is backed up before beginning the
248 installation process.
249
250 Default answers are displayed in brackets after the questions.
251 You can hit Control-C at any time to quit, but if you do so at a
252 prompt, you may have to hit return. Also, quitting in the middle of
253 installation may leave your system in an inconsistent state.
254
255 __welcome_banner_3
256 }
257
258 md_not_going_to_install() {
259 cat << \__not_going_to_install_1
260
261 OK, then. Enter `halt' at the prompt to halt the machine. Once the
262 machine has halted, power-cycle the system to load new boot code.
263
264 Note: If you wish to have another try. Just type '^D' at the prompt. After
265 a moment, the installer will restart itself.
266
267 __not_going_to_install_1
268 }
269
270 md_congrats() {
271 local what;
272 if [ "$MODE" = "install" ]; then
273 what="installed";
274 else
275 what="upgraded";
276 fi
277 cat << __congratulations_1
278
279 CONGRATULATIONS! You have successfully $what NetBSD!
280 To boot the installed system, enter halt at the command prompt. Once the
281 system has halted, reset the machine and boot from the disk.
282
283 Note: If you wish to have another try. Just type '^D' at the prompt. After
284 a moment, the installer will restart itself.
285
286 __congratulations_1
287 }
288
289 md_copy_kernel() {
290 # This is largely a copy of install_disk and install_from_mounted_fs()
291 # with some special frobbing.
292
293 local _directory
294 local _sets
295 local _filename
296 local _f
297
298 if [ -e /netbsd ]; then
299 echo -n "Copying kernel..."
300 cp -p /netbsd /mnt/netbsd
301 echo "done."
302 return
303 fi
304
305 cat << \__md_copy_kernel_1
306 Your installation set did not include a netbsd kernel on the installation
307 filesystem. You are now given the opportunity install it from either the
308 kernel-floppy from the distribution or another location on one of your disks.
309
310 The following disk devices are installed on your system; please select
311 the disk device containing the partition with the netbsd kernel:
312 __md_copy_kernel_1
313
314 _DKDEVS=`md_get_diskdevs`
315 echo "$_DKDEVS"
316 echo "fd0"
317 echo ""
318 _DKDEVS="$_DKDEVS fd0" # Might be on the kernel floppy!
319 echo -n "Which is the disk with the kernel? [abort] "
320
321 if mount_a_disk ; then
322 return # couldn't mount the disk
323 fi
324
325 # Get the directory where the file lives
326 resp="" # force one iteration
327 while [ "X${resp}" = X"" ]; do
328 echo "Enter the directory relative to the mount point that"
329 echo -n "contains the file. [${_directory}] "
330 getresp "${_directory}"
331 done
332 _directory=$resp
333
334 _sets=`(cd /mnt2/$_directory; ls netbsd* 2> /dev/null)`
335 if [ -z "$_sets" ]; then
336 echo "There are no NetBSD kernels available in \"$1\""
337 umount -f /mnt2 > /dev/null 2>&1
338 return
339 fi
340 while : ; do
341 echo "The following kernels are available:"
342 echo ""
343
344 for _f in $_sets ; do
345 echo " $_f"
346 done
347 echo ""
348 set -- $_sets
349 echo -n "File name [$1]? "
350 getresp "$1"
351 _f=$resp
352 _filename="/mnt2/$_directory/$_f"
353
354 # Ensure file exists
355 if [ ! -f $_filename ]; then
356 echo "File $_filename does not exist. Check to make"
357 echo "sure you entered the information properly."
358 echo -n "Do you want to retry [y]? "
359 getresp "y"
360 if [ "$resp" = "n" ]; then
361 break
362 fi
363 continue
364 fi
365
366 # Copy the kernel
367 cp $_filename /mnt
368 break
369 done
370 umount -f /mnt2 > /dev/null 2>&1
371 }
372