install.sh revision 1.1.1.1.34.1
1#!/bin/sh
2#	$NetBSD: install.sh,v 1.1.1.1.34.1 2008/06/02 13:21:12 mjf Exp $
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#
19# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31
32#	NetBSD installation script.
33#	In a perfect world, this would be a nice C program, with a reasonable
34#	user interface.
35
36FILESYSTEMS="/tmp/filesystems"		# used thoughout
37MODE="install"
38
39# include machine-dependent functions
40# The following functions must be provided:
41#	md_prep_disklabel()	- label the root disk
42#	md_welcome_banner()	- display friendly message
43#	md_congrats()		- display friendly message
44#	md_makerootwritable()	- make root writable (at least /tmp)
45
46# we need to make sure .'s below work if this directory is not in $PATH
47# dirname may not be available but expr is
48Mydir=`expr $0 : '^\(.*\)/[^/]*$'`
49Mydir=`cd ${Mydir:-.}; pwd`
50
51#
52# Sub-parts
53#
54getresp() {
55	read resp
56	if [ "X$resp" = "X" ]; then
57		resp=$1
58	fi
59}
60
61isin() {
62# test the first argument against the remaining ones, return succes on a match
63	_a=$1; shift
64	while [ $# != 0 ]; do
65		if [ "$_a" = "$1" ]; then return 0; fi
66		shift
67	done
68	return 1
69}
70
71getrootdisk() {
72	cat << \__getrootdisk_1
73
74The installation program needs to know which disk to consider
75the root disk.  Note the unit number may be different than
76the unit number you used in the standalone installation
77program.
78
79Available disks are:
80
81__getrootdisk_1
82	_DKDEVS=`md_get_diskdevs`
83	echo	"$_DKDEVS"
84	echo	""
85	echo -n	"Which disk is the root disk? "
86	getresp ""
87	if isin $resp $_DKDEVS ; then
88		ROOTDISK="$resp"
89	else
90		echo ""
91		echo "The disk $resp does not exist."
92		ROOTDISK=""
93	fi
94}
95
96labelmoredisks() {
97	cat << \__labelmoredisks_1
98
99You may label the following disks:
100
101__labelmoredisks_1
102	echo "$_DKDEVS"
103	echo	""
104	echo -n	"Label which disk? [done] "
105	getresp "done"
106	case "$resp" in
107		"done")
108			;;
109
110		*)
111			if isin $resp $_DKDEVS ; then
112				md_labeldisk $resp
113			else
114				echo ""
115				echo "The disk $resp does not exist."
116			fi
117			;;
118	esac
119}
120
121#
122# include machine dependent subroutines
123. $Mydir/install.md
124
125# Good {morning,afternoon,evening,night}.
126md_welcome_banner
127echo -n "Proceed? [n] "
128getresp "n"
129case "$resp" in
130	y*|Y*)
131		echo	"Cool!  Let's get to it..."
132		;;
133	*)
134		md_not_going_to_install
135		exit
136		;;
137esac
138
139# XXX Work around vnode aliasing bug (thanks for the tip, Chris...)
140ls -l /dev > /dev/null 2>&1
141
142# Deal with terminal issues
143md_set_term
144
145# Make sure we can write files (at least in /tmp)
146# This might make an MFS mount on /tmp, or it may
147# just re-mount the root with read-write enabled.
148md_makerootwritable
149
150while [ "X${ROOTDISK}" = "X" ]; do
151	getrootdisk
152done
153
154# Deal with disklabels, including editing the root disklabel
155# and labeling additional disks.  This is machine-dependent since
156# some platforms may not be able to provide this functionality.
157md_prep_disklabel ${ROOTDISK}
158
159# Pat on the back.
160md_congrats
161
162# ALL DONE!
163exit 0
164