Sync usage with man page.
[netbsd-mini2440.git] / distrib / amiga / floppies / inst / install.sh
blob4309bfb11836edbfba74d03cf32b60bee422a55d
1 #!/bin/sh
2 # $NetBSD: install.sh,v 1.8 2000/06/14 17:24:11 cgd Exp $
4 # Copyright (c) 1994 Christopher G. Demetriou
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed for the
18 # NetBSD Project. See http://www.NetBSD.org/ for
19 # information about NetBSD.
20 # 4. The name of the author may not be used to endorse or promote products
21 # derived from this software without specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 # <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
36 # NetBSD installation script.
37 # In a perfect world, this would be a nice C program, with a reasonable
38 # user interface.
40 FSTABDIR=/mnt/etc # /mnt/etc
41 #DONTDOIT==echo
43 VERSION=1.2
44 FSTAB=${FSTABDIR}/fstab
46 getresp() {
47 read resp
48 if [ "X$resp" = "X" ]; then
49 resp=$1
53 getvar() {
54 echo $(eval $(echo "echo \$$1"))
57 shiftvar() {
58 local - var
59 var="$1"
60 list="$(getvar $var)"
61 set -- $list
62 shift
63 setvar $var "$*"
66 getparts() {
67 disklabel $1 2>/dev/null | sed -e '/^[ ][ ][ad-p]/!d' |
68 sed -e 's,^[ ]*\([a-p]\):[ ]*[0-9]*[ ]*[0-9]*[ ][ ]*\([a-zA-Z0-9.]*\).*,\1 \2,' |
69 sed -e ':a
70 N;${s/\n/ /g;p;d;}
71 ba'
74 getdrives() {
75 local du thispart
76 for du in /dev/r${drivetype}?a; do
77 dd if=$du of=/dev/null bs=1b count=1 >/dev/null 2>&1
78 if [ $? -eq 0 ]; then
79 thisunit=`echo $du | sed -e 's,/dev/r\(...\)a,\1,g'`
80 driveunits="$driveunits $thisunit"
81 else
82 continue;
84 setvar $thisunit "$(getparts $thisunit)"
85 export $thisunit
86 done
87 export drivenunits
90 prepdrive() {
91 echo "which drive would you like to prepare next?"
92 echo "choices are: ${driveunits}"
93 echo ""
94 getresp
95 case $resp in
96 *) ;;
97 esac
100 echo "Welcome to the NetBSD ${VERSION} installation program."
101 echo ""
102 echo "This program is designed to help you put NetBSD on your hard disk,"
103 echo "in a simple and rational way. Its main objective is to format,"
104 echo "mount and create an fstab for your root (/) and user (/usr)"
105 echo "partitions."
106 echo ""
107 echo "As with anything which modifies your hard drive's contents, this"
108 echo "program can cause SIGNIFICANT data loss, and you are advised"
109 echo "to make sure your hard drive is backed up before beginning the"
110 echo "installation process."
111 echo ""
112 echo "Default answers are displayed in brackets after the questions."
113 echo "You can hit Control-C at any time to quit, but if you do so at a"
114 echo "prompt, you may have to hit return. Also, quitting in the middle of"
115 echo "installation may leave your system in an inconsistent state."
116 echo ""
117 echo -n "Proceed with installation? [n] "
118 getresp "n"
119 case "$resp" in
120 y*|Y*)
121 echo "scanning for the root device"
124 echo ""
125 echo "OK, then. Enter 'halt' at the prompt to halt the"
126 echo "machine. Once the machine has halted, remove the"
127 echo "floppy and press any key to reboot."
128 exit
130 esac
132 drivetype=sd
133 sect_fwd=""
135 # find out what units are possible for that disk, and query the user.
136 getdrives
137 for du in $driveunits; do
138 set -- $(getvar $du)
139 if [ $# -ge 2 -a "$1" = "a" -a "`echo $2 | sed -e 's,.*BSD.*,BSD,'`" = "BSD" ]; then
140 rdev=$du
142 done
144 echo ""
145 echo "The following root devices are available on your machine:"
146 echo " "${driveunits}
147 echo ""
148 prefdev=${rdev}
149 rdev=""
150 while [ "X${rdev}" = "X" ]; do
151 echo -n "Which device would you like to install on ? [${prefdev}] "
152 getresp ${prefdev}
153 otherdrives=`echo "${driveunits}" | sed -e s,${resp},,`
154 if [ "X${driveunits}" = "X${otherdrives}" ]; then
155 echo ""
156 echo "\"${resp}\" is an invalid drive name. Valid choices"
157 echo "are: "${driveunits}
158 else
159 rdev=${resp}
161 done
163 echo ""
164 echo "The root device you have chosen is on: ${rdev}"
165 echo ""
166 # driveunits=`ls /dev/${drivetype}?a | sed -e 's,/dev/\(...\)a,\1,g'`
167 if [ "X${driveunits}" = "X" ]; then
168 echo "FATAL ERROR:"
169 echo "No devices for disks of type '${drivetype}'."
170 echo "This is probably a bug in the install disks."
171 echo "Exiting install program."
172 exit
175 echo ""
176 echo "THIS IS YOUR LAST CHANCE!!!"
177 echo ""
178 echo "(answering yes will format your root partition on $rdev)"
179 echo -n "Are you SURE you want NetBSD installed on your hard drive? (yes/no) "
180 answer=""
181 while [ "$answer" = "" ]; do
182 getresp
183 case $resp in
184 yes|YES)
185 echo ""
186 answer=yes
188 no|NO)
189 echo ""
190 echo -n "OK, then. enter 'halt' to halt the machine. "
191 echo "Once the machine has halted,"
192 echo -n "remove the floppy, and press any key to "
193 echo "reboot."
194 exit
197 echo -n "I want a yes or no answer... well? "
199 esac
200 done
201 echo "Initializing / (root) filesystem, and mounting..."
202 $DONTDOIT newfs /dev/r${rdev}a $name
203 $DONTDOIT mount -v /dev/${rdev}a /mnt
204 echo ""
205 echo -n "Creating a fstab..."
206 mkdir -p $FSTABDIR
207 echo "/dev/${rdev}a / ffs rw 1 1" > $FSTAB
209 # get rid of this partition
210 shiftvar $rdev
211 shiftvar $rdev
213 echo ""
214 echo "Now lets setup your /usr file system"
215 echo "(Once a valid input for drive and partition is seen"
216 echo "it will be FORMATTED and inserted in the fstab.)"
217 while [ "X$usrpart" = "X" ]; do
218 resp=""
219 drivename=""
220 while [ "X$resp" = "X" ]; do
221 echo "choices: $driveunits"
222 echo "which drive do you want /usr on?"
223 getresp
224 set -- $driveunits
225 while [ $# -gt 0 ]; do
226 if [ "X$resp" = "X$1" ]; then
227 drivename=$1
228 break;
229 else
230 shift
232 done
233 if [ "X$drivename" != "X" ]; then
234 break
236 done
238 usrpart=""
239 echo "You have selected $drivename"
240 echo "here is a list of partitions on $drivename"
241 disklabel $drivename 2>/dev/null | sed -e '/^[ ][ ][ad-p]:/p;/^#[ \t]*size/p;d'
242 echo "which partition would you like to format and have"
243 echo -n "mounted as /usr? (supply the letter): "
244 getresp
245 if [ "X$resp" = "X" ]; then
246 continue;
249 list=$(getvar $drivename)
250 set -- $list
251 while [ $# -gt 0 ]; do
252 if [ "$resp" = "$1" ]; then
253 if [ "`echo $2 | sed -e 's,.*BSD.*,BSD,'`" != "BSD" ]; then
254 echo ""
255 echo -n "$drivename$resp is of type $2 which is not"
256 echo " a BSD filesystem type"
257 break
259 usrpart=$drivename$resp
260 break
261 else
262 shift
263 shift
265 done
266 if [ "X$usrpart" = "X" ]; then
267 echo "$resp is not a valid input."
268 echo ""
270 done
272 echo ""
273 echo "Initializing /usr filesystem, and mounting..."
274 $DONTDOIT newfs /dev/r${usrpart} $name
275 $DONTDOIT mkdir -p /mnt/usr
276 $DONTDOIT mount -v /dev/${usrpart} /mnt/usr
277 echo ""
278 echo -n "Adding to fstab..."
279 echo "/dev/${usrpart} /usr ffs rw 1 2" >> $FSTAB
280 sync
281 echo " done."
283 echo ""
284 echo "OK! The preliminary work of setting up your disk is now complete,"
285 echo "and you can install the actual NetBSD software."
286 echo ""
287 echo "Right now, your root is mounted on /mnt and your usr on /mnt/usr."
288 echo "You should consult the installation notes to determine how to load"
289 echo "and install the NetBSD distribution sets, and how to configure your"
290 echo "system when you are done."
291 echo ""
292 echo "GOOD LUCK!"
293 echo ""