xref: /netbsd/distrib/mvme68k/miniroot/install.md (revision 6550d01e)
1#!/bin/sh
2#
3#	$NetBSD: install.md,v 1.6 2010/03/10 23:13:09 abs Exp $
4#
5# Copyright (c) 1996 The NetBSD Foundation, Inc.
6# All rights reserved.
7#
8# This code is derived from software contributed to The NetBSD Foundation
9# by Jason R. Thorpe.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14# 1. Redistributions of source code must retain the above copyright
15#    notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright
17#    notice, this list of conditions and the following disclaimer in the
18#    documentation and/or other materials provided with the distribution.
19#
20# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30# POSSIBILITY OF SUCH DAMAGE.
31#
32
33#
34# machine dependent section of installation/upgrade script
35#
36
37# Machine-dependent install sets
38MDSETS=""
39
40md_set_term() {
41	if [ ! -z "$TERM" ]; then
42		return
43	fi
44	echo -n "Specify terminal type [vt100]: "
45	getresp "vt100"
46	TERM="$resp"
47	export TERM
48	# XXX call tset?
49}
50
51__mount_kernfs() {
52	# Make sure kernfs is mounted.
53	if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
54		mkdir /kern > /dev/null 2>&1
55		/sbin/mount_kernfs /kern /kern >/dev/null 2>&1
56	fi
57}
58
59md_makerootwritable() {
60	# Just remount the root device read-write.
61	__mount_kernfs
62	echo "Remounting root read-write..."
63	mount -t ffs -u /kern/rootdev /
64}
65
66md_get_diskdevs() {
67	# return available disk devices
68	__mount_kernfs
69	sed -n -e '/^sd[0-9] /s/ .*//p' \
70		< /kern/msgbuf | sort -u
71}
72
73md_get_cddevs() {
74	# return available CDROM devices
75	__mount_kernfs
76	sed -n -e '/^cd[0-9] /s/ .*//p' \
77		< /kern/msgbuf | sort -u
78}
79
80md_get_ifdevs() {
81	# return available network devices
82	__mount_kernfs
83	sed -n -e '/^le[0-9] /s/ .*//p' \
84	       -e '/^ie[0-9] /s/ .*//p' \
85		< /kern/msgbuf | sort -u
86}
87
88md_get_partition_range() {
89	# return an expression describing the valid partition id's
90	echo '[a-h]'
91}
92
93md_installboot() {
94	# install the boot block on disk $1
95	echo "Installing boot block..."
96	( cd /usr/mdec ;\
97	cp -p ./bootsd /mnt/.bootsd ;\
98	sync ; sleep 1 ; sync ;\
99	./installboot -v /mnt/.bootsd bootxx /dev/r${1}a )
100	echo "done."
101}
102
103md_native_fstype() {
104}
105
106md_native_fsopts() {
107}
108
109grep_check () {
110	pattern=$1; shift
111	awk 'BEGIN{ es=1; } /'"$pattern"'/{ print; es=0; } END{ exit es; }' "$@"
112}
113
114md_checkfordisklabel() {
115	# $1 is the disk to check
116	local rval
117
118	disklabel $1 > /dev/null 2> /tmp/checkfordisklabel
119	if grep_check "no disklabel" /tmp/checkfordisklabel; then
120		rval=1
121	elif grep_check "disk label corrupted" /tmp/checkfordisklabel; then
122		rval=2
123	else
124		rval=0
125	fi
126
127	rm -f /tmp/checkfordisklabel
128	return $rval
129}
130
131md_prep_disklabel()
132{
133	local _disk
134
135	_disk=$1
136	md_checkfordisklabel $_disk
137	case $? in
138	0)
139		echo -n "Do you wish to edit the disklabel on $_disk? [y]"
140		;;
141	1)
142		echo "WARNING: Disk $_disk has no label"
143		echo -n "Do you want to create one with the disklabel editor? [y]"
144		;;
145	2)
146		echo "WARNING: Label on disk $_disk is corrupted"
147		echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
148		;;
149	esac
150
151	getresp "y"
152	case "$resp" in
153	y*|Y*) ;;
154	*)	return ;;
155	esac
156
157	# display example
158	cat << \__md_prep_disklabel_1
159
160Here is an example of what the partition information will look like once
161you have entered the disklabel editor. Disk partition sizes and offsets
162are in sector (most likely 512 bytes) units. Make sure these size/offset
163pairs are on cylinder boundaries (the number of sector per cylinder is
164given in the `sectors/cylinder' entry, which is not shown here).
165
166Do not change any parameters except the partition layout and the label name.
167It's probably also wisest not to touch the `8 partitions:' line, even
168in case you have defined less than eight partitions.
169
170[Example]
1718 partitions:
172#        size   offset    fstype   [fsize bsize   cpg]
173  a:    50176        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 111)
174  b:    64512    50176      swap                        # (Cyl.  112 - 255)
175  c:   640192        0   unknown                        # (Cyl.    0 - 1428)
176  d:   525504   114688    4.2BSD     1024  8192    16   # (Cyl.  256 - 1428)
177[End of example]
178
179__md_prep_disklabel_1
180	echo -n "Press [Enter] to continue "
181	getresp ""
182	disklabel -i -I /dev/r${_disk}c
183}
184
185md_copy_kernel() {
186	echo -n "Copying kernel..."
187	cp -p /netbsd /mnt/netbsd
188	echo "done."
189}
190
191md_welcome_banner() {
192	echo	"Welcome to the NetBSD/mvme68k ${VERSION} installation program."
193	cat << \__welcome_banner_1
194
195This program is designed to help you install NetBSD on your system in a simple
196and rational way.  You'll be asked several questions, and it would probably be
197useful to have your disk's hardware manual, the installation notes, and a
198calculator handy.
199
200In particular, you will need to know some reasonably detailed information
201about your disk's geometry. The kernel will attempt to display geometry
202information for SCSI disks during boot, if possible. If you did not make it
203note of it before, you may wish to reboot and jot down your disk's geometry
204before proceeding.
205
206As with anything which modifies your hard disk's contents, this program can
207cause SIGNIFICANT data loss, and you are advised to make sure your hard drive
208is backed up before beginning the installation process.
209
210Default answers are displyed in brackets after the questions. You can hit
211Control-C at any time to quit, but if you do so at a prompt, you may have to
212hit return.  Also, quitting in the middle of installation may leave your
213system in an inconsistent state.
214__welcome_banner_1
215}
216
217md_not_going_to_install() {
218		cat << \__not_going_to_install_1
219
220OK, then.  Enter 'halt' at the prompt to halt the machine.  Once the
221machine has halted, power-cycle the system to load new boot code.
222
223__not_going_to_install_1
224}
225
226md_congrats() {
227	cat << \__congratulations_1
228
229CONGRATULATIONS!  You have successfully installed NetBSD!  To boot the
230installed system, enter halt at the command prompt.  Once the system has
231halted, power-cycle the machine in order to load new boot code.  Make sure
232you boot from the root disk.
233
234__congratulations_1
235}
236
237md_native_fstype() {
238	# Nothing to do.
239}
240
241md_native_fsopts() {
242	# Nothing to do.
243}
244