]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/instdist.sh
Fix an obscure message that went off the right hand side.
[FreeBSD/FreeBSD.git] / release / instdist.sh
1 #!/stand/sh
2 #
3 # instdist - Install a distribution from some sort of media.
4 #
5 # Written:  November 11th, 1994
6 # Copyright (C) 1994 by Jordan K. Hubbard
7 #
8 # Permission to copy or use this software for any purpose is granted
9 # provided that this message stay intact, and at this location (e.g. no
10 # putting your name on top after doing something trivial like reindenting
11 # it, just to make it look like you wrote it!).
12 #
13 # $Id: instdist.sh,v 1.24 1994/11/21 07:25:27 jkh Exp $
14
15 if [ "$_INSTINST_SH_LOADED_" = "yes" ]; then
16         return 0
17 else
18         _INSTINST_SH_LOADED_=yes
19 fi
20
21 # Grab the miscellaneous functions.
22 . /stand/miscfuncs.sh
23
24 # Set some reasonable defaults.
25 TAR=tar
26 TAR_FLAGS="--unlink -xvf"
27 MNT=/mnt
28
29 # Set the initial state for media installation.
30 media_set_defaults()
31 {
32         media_type=""
33         media_device=""
34         media_distribution=""
35         distrib_subdir=""
36         clear=""
37         ipaddr=""
38         hostname=""
39         ether_intr=""
40         domain=""
41         netmask="0xffffff00"
42         ifconfig_flags=""
43         remote_hostip=""
44         tmp_dir="/usr/tmp"
45         ftp_path=""
46         nfs_path=""
47         nfs_options=""
48         serial_interface="/dev/tty00"
49         serial_speed="38400"
50 }
51
52 # Set the installation media to undefined.
53 media_reset()
54 {
55         media_device=""
56         media_type=""
57         media_distribution=""
58 }
59
60 # Set the location of our temporary unpacking directory.
61 media_set_tmpdir()
62 {
63         title="Chose temporary directory"
64         default_value="/usr/tmp"
65         if ! input \
66 "Please specify the name of a directory containing enough free
67 space to hold the temporary files for this distribution.  At
68 minimum, a binary distribution will require around 21MB of
69 temporary space.  At maximum, a srcdist may take 30MB or more.
70 If the directory you specify does not exist, it will be created
71 for you.  If you do not have enough free space to hold both the
72 packed and unpacked distribution files, consider using the NFS
73 or CDROM installation methods as they require no temporary
74 storage."; then return 1; fi
75         tmp_dir=$answer
76         mkdir -p $tmp_dir
77         return 0
78 }
79
80 media_cd_tmpdir()
81 {
82         if ! cd $tmp_dir > /dev/ttyv1 2>&1; then
83                 error "No such file or directory for ${tmp_dir}, sorry!  Please fix this and try again."
84                 return 1
85         fi
86 }
87
88 media_rm_tmpdir()
89 {
90         cd /
91         if dialog --title "Delete contents?" $clear --yesno \
92           "Do you wish to delete the contents of ${tmp_dir}?" -1 -1; then
93                 rm -rf $tmp_dir/*
94         fi
95 }
96
97 media_select_ftp_site()
98 {
99         dialog $clear --title "Please specify an ftp site" \
100         --menu \
101 "FreeBSD is distributed from a number of sites on the Internet.\n\
102 Please select the site closest to you or \"other\" if you'd like\n\
103 to specify another choice.  Also note that not all sites carry\n\
104 every possible distribution!  Distributions other than the basic\n\
105 binary set are only guaranteed to be available from the Primary site." \
106 -1 -1 10 \
107    "Primary" "ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}" \
108    "U.S-2" "ftp://ftp.dataplex.net/pub/FreeBSD/${DISTNAME}" \
109    "U.S-3" "ftp://kryten.atinc.com/pub/FreeBSD/${DISTNAME}" \
110    "U.S-4" "ftp://ref.tfs.com/pub/FreeBSD/${DISTNAME}" \
111    "Taiwan" "ftp://netbsd.csie.nctu.edu.tw/pub/FreeBSD/${DISTNAME}" \
112    "Australia" "ftp://ftp.physics.usyd.edu.au/FreeBSD/${DISTNAME}" \
113    "France" "ftp://ftp.ibp.fr/pub/freeBSD/${DISTNAME}" \
114    "Finland" "ftp://nic.funet.fi:/pub/unix/FreeBSD/${DISTNAME}" \
115    "Russia" "ftp://ftp.kiae.su/FreeBSD/${DISTNAME}" \
116    "other" "None of the above.  I want to specify my own." \
117       2> ${TMP}/menu.tmp.$$
118         retval=$?
119         answer=`cat ${TMP}/menu.tmp.$$`
120         rm -f ${TMP}/menu.tmp.$$
121         if ! handle_rval $retval; then return 1; fi
122         case $answer in
123         Primary)
124                 ftp_path="ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}"
125         ;;
126
127         U.S-2)
128                 ftp_path="ftp://ftp.dataplex.net/pub/FreeBSD/${DISTNAME}"
129         ;;
130
131         U.S-3)
132                 ftp_path="ftp://kryten.atinc.com/pub/FreeBSD/${DISTNAME}"
133         ;;
134
135         U.S-4)
136                 ftp_path="ftp://ref.tfs.com/pub/FreeBSD/${DISTNAME}"
137         ;;
138
139         Taiwan)
140                 ftp_path="ftp://netbsd.csie.nctu.edu.tw/pub/FreeBSD/${DISTNAME}"
141         ;;
142
143         Australia)
144                 ftp_path="ftp://ftp.physics.usyd.edu.au/FreeBSD/${DISTNAME}"
145         ;;
146
147         France)
148                 ftp_path="ftp://ftp.ibp.fr/pub/freeBSD/${DISTNAME}"
149         ;;
150
151         Finland)
152                 ftp_path="ftp://nic.funet.fi:/pub/unix/FreeBSD/${DISTNAME}"
153         ;;
154
155         Russia)
156                 ftp_path="ftp://ftp.kiae.su/FreeBSD/${DISTNAME}"
157         ;;
158
159         other)
160                 title="FTP Installation Information"
161                 default_value="$ftp_path"
162                 if ! input \
163 "Please specify the machine and directory location of the
164 distribution you wish to load.  This should be either a \"URL style\"
165 specification (e.g. ftp://ftp.freeBSD.org/pub/FreeBSD/...) or simply
166 the name of a host to connect to.  If only a host name is specified,
167 the installation assumes that you will properly connect and \"mget\"
168 the files yourself."; then return 1; fi
169                 ftp_path=$answer
170         ;;
171         esac
172 }
173
174 media_extract_dist()
175 {
176         if [ -f do_cksum.sh ]; then
177                 message "Verifying checksums for distribution.  Please wait!"
178                 if sh ./do_cksum.sh; then
179                         if [ -f extract.sh ]; then
180                                 message "Extracting ${media_distribution} distribution.  Please wait!"
181                                 sh ./extract.sh < /dev/ttyv1 > /dev/ttyv1 2>&1
182                                 dialog $clear --title "Extraction Complete" --msgbox "Please press return to continue" -1 -1
183                         else
184                                 error "No installation script found!"
185                         fi
186                 else
187                         error "Checksum error(s) found.  Please check media!"
188                 fi
189         else    
190                 error "Improper distribution.  No checksum script found!"
191         fi
192 }
193
194 media_install_set()
195 {
196         case $media_type in
197         cdrom|nfs|ufs|doshd)
198                 if ! cd ${media_device}/${media_distribution} > /dev/ttyv1 2>&1; then
199                         error "Unable to cd to ${media_device}/${media_distribution} directory."
200                         media_reset
201                 else
202                         media_extract_dist
203                         cd /
204                 fi
205                 return
206         ;;
207
208         tape)
209                 if ! media_set_tmpdir; then return; fi
210                 if ! media_cd_tmpdir; then return; fi
211                 confirm "Please mount tape for ${media_device}."
212                 if [ "$media_device" = "ftape" ]; then
213                         dialog --title "Results of tape extract" $clear \
214                           --prgbox "ft | $TAR $TAR_FLAGS -" 10 72
215                 else
216                         dialog --title "Results of tape extract" $clear \
217                           --prgbox "$TAR $TAR_FLAGS $media_device" 10 72
218                 fi
219                 media_extract_dist
220                 media_rm_tmpdir
221         ;;
222
223         dosfd)
224                 if ! media_set_tmpdir; then return; fi
225                 if ! media_cd_tmpdir; then return; fi
226                 copying="yes"
227                 while [ "$copying" = "yes" ]; do
228                         if dialog --title "Insert distribution diskette" \
229                           $clear --yesno "Please enter the next diskette and press OK to continue or Cancel if finished" -1 -1; then
230                                 umount ${MNT} > /dev/null 2>&1
231                                 if ! mount_msdos ${media_device} ${MNT}; then
232                                         error "Unable to mount floppy!  Please correct."
233                                 else
234                                         ( tar -cf - -C ${MNT} . | tar -xvf - ) >/dev/ttyv1 2>&1
235                                         umount ${MNT}
236                                 fi
237                         else
238                                 copying="no"
239                         fi
240                 done
241                 media_extract_dist
242                 media_rm_tmpdir
243                 return
244         ;;
245
246         ftp)
247                 if ! media_set_tmpdir; then return; fi
248                 if ! media_cd_tmpdir; then return; fi
249                 if ! echo $media_device | grep -q -v 'ftp://'; then
250                         message "Fetching distribution using ncftp.\nUse ALT-F2 to see output, ALT-F1 to return."
251                         if ! ncftp $media_device/${media_distribution}/* < /dev/null > /dev/ttyv1 2>&1; then
252                                 error "Couldn't fetch ${media_distribution} distribution from\n${media_device}!"
253                         else
254                                 media_extract_dist
255                         fi
256                 else
257                         dialog --clear
258                         ftp $media_device
259                         dialog --clear
260                         media_extract_dist
261                 fi
262                 media_rm_tmpdir
263                 return
264         ;;
265         esac
266 }
267
268 media_select_distribution()
269 {
270         media_distribution=""
271         while [ "$media_distribution" = "" ]; do
272
273         dialog $clear --title "Please specify a distribution to load" \
274         --menu \
275 "FreeBSD is separated into a number of distributions for ease of\n\
276 installation.  With repeated passes through this screen, you'll be\n\
277 given the chance to load one or all of them.  Mandatory distributions\n\
278 MUST be loaded!  Please also note that the secrdist is NOT FOR EXPORT\n\
279 from the U.S.  Please don't endanger U.S. ftp sites by getting it\n\
280 illegally, thanks!  When finished, select <Cancel>." \
281 -1 -1 10 \
282   "?diskfree"  "How much disk space do I have free?" \
283   "bindist" "Binary base files (mandatory - $BINSIZE)" \
284   "games" "Games and other frivolities (optional - $GAMESIZE)" \
285   "manpages" "Manual pages (optional - $MANSIZE)" \
286   "proflibs" "Profiled libraries (optional - $PROFSIZE)" \
287   "dict" "Spelling checker dictionary files (optional - $DICTSIZE)" \
288   "srcdist" "Sources for everything but DES (optional - $SRCSIZE)" \
289   "secrdist" "DES encryption code (and sources) (optional - $SECRSIZE)" \
290   "compat1xdist" "FreeBSD 1.x binary compatability (optional - $COMPATSIZE)" \
291   "XFree86-3.1" "The XFree86 3.1 distribution (optional - $X11SIZE)" \
292      2> ${TMP}/menu.tmp.$$
293         retval=$?
294         media_distribution=`cat ${TMP}/menu.tmp.$$`
295         rm -f ${TMP}/menu.tmp.$$
296         if ! handle_rval $retval; then return 1; fi
297         if [ "$media_distribution" = "?diskfree" ]; then
298                 if df -k > ${TMP}/df.out; then
299                         dialog $clear \
300                         --title "How much free space do I have?" \
301                         --textbox ${TMP}/df.out 15 76
302                 else
303                         error "Couldn't get disk usage information! :-("
304                 fi
305                 media_distribution=""
306         fi
307         done
308 }
309
310 media_get_possible_subdir()
311 {
312         default_value="$distrib_subdir"
313         title="Distribution Subdirectory"
314         if input \
315 "If the distributions are in a subdirectory of the mount point,
316 please enter it here (no leading slash - it should be relative
317 to the mount point).  The directory you enter should be the
318 *parent* directory of any distribution subdirectories."; then
319                 if [ "$answer" != "" ]; then
320                         media_device=${media_device}/$answer
321                         distrib_subdir=$answer
322                 fi
323         fi
324 }
325
326 # Get values into $media_type and $media_device.  Call network initialization
327 # if necessary.
328 media_chose()
329 {
330         while [ "$media_device" = "" ]; do
331
332         dialog $clear --title "Installation From" \
333 --menu \
334 "Before installing a distribution, you need to chose and/or configure\n\
335 a method of installation.  Please pick from one of the following options.\n\
336 If none of the listed options works for you, then your best bet may be to\n\
337 simply hit ESC twice to get a subshell and proceed manually on your own.\n\
338 If you are already finished with the installation process, select cancel\n\
339 to proceed." -1 -1 7 \
340         "?Kern" "Please show me the kernel boot messages again!" \
341         "Tape" "Load distribution from SCSI, QIC or floppy tape" \
342         "CDROM" "Load distribution from SCSI or Mitsumi CDROM" \
343         "DOS" "Load from DOS floppies or a DOS hard disk partition" \
344         "FTP" "Load distribution using FTP" \
345         "UFS" "Load the distribution from existing UFS partition" \
346         "NFS" "Load the distribution over NFS" 2> ${TMP}/menu.tmp.$$
347         retval=$?
348         choice=`cat ${TMP}/menu.tmp.$$`
349         rm -f ${TMP}/menu.tmp.$$
350         if ! handle_rval $retval; then return 1; fi
351
352         case $choice in
353         ?Kern)
354                 if dmesg > ${TMP}/dmesg.out; then
355                         dialog $clear \
356                         --title "What do I have in this machine again?" \
357                         --textbox ${TMP}/dmesg.out 22 76
358                 else
359                         error "Couldn't get dmesg information! :-("
360                 fi
361         ;;
362
363         Tape)
364                 dialog $clear --title "Chose Tape Type" \
365 --menu "Which type of tape drive do you have attached to your \n\
366 system?  FreeBSD supports the following types:\n" -1 -1 3 \
367                 "SCSI" "SCSI tape drive attached to supported SCSI controller" \
368                 "QIC" "QIC tape drive (Colorado Jumbo, etc)" \
369                 "floppy" "Floppy tape drive" \
370                         2> ${TMP}/menu.tmp.$$
371                 retval=$?
372                 choice=`cat ${TMP}/menu.tmp.$$`
373                 rm -f ${TMP}/menu.tmp.$$
374                 if ! handle_rval $retval; then continue; fi
375                 media_type=tape;
376                 case $choice in
377                         SCSI)
378                                 media_device=/dev/rst0
379                         ;;
380                         QIC)
381                                 media_device=/dev/rwt0
382                         ;;
383                         floppy)
384                                 media_device=ftape
385                         ;;
386                 esac
387         ;;
388
389         CDROM)
390                 dialog $clear --title "Chose CDROM Type" \
391 --menu "Which type of CDROM drive do you have attached to your \n\
392 system?  FreeBSD supports the following types:\n" -1 -1 2 \
393                 "SCSI" "SCSI CDROM drive attached to supported SCSI controller" \
394                 "Mitsumi" "Mitsumi CDROM drive" \
395                         2> ${TMP}/menu.tmp.$$
396                 retval=$?
397                 choice=`cat ${TMP}/menu.tmp.$$`
398                 rm -f ${TMP}/menu.tmp.$$
399                 if ! handle_rval $retval; then continue; fi
400                 media_type=cdrom;
401                 case $choice in
402                         SCSI)
403                                 media_device=/dev/cd0a
404                         ;;
405                         Mitsumi)
406                                 media_device=/dev/mcd0a
407                         ;;
408                 esac
409                 umount ${MNT} > /dev/null 2>&1
410                 if ! mount_cd9660 $media_device ${MNT} > /dev/ttyv1 2>&1; then
411                         error "Unable to mount $media_device on ${MNT}"
412                         media_device=""
413                 else
414                         media_device=${MNT}
415                         media_get_possible_subdir
416                 fi
417         ;;
418
419         DOS)
420                 default_value="/dev/fd0"
421                 if input \
422 "Please specify the device pointing at your DOS partition or
423 floppy media.  For a hard disk, this might be something like
424 /dev/wd0h or /dev/sd0h (as identified in the disklabel editor).
425 For the "A" floppy drive, it's /dev/fd0, for the "B" floppy
426 drive it's /dev/fd1\n"; then
427                         media_device=$answer
428                         if echo $media_device | grep -q -v 'fd://'; then
429                                 umount ${MNT} > /dev/null 2>&1
430                                 if ! mount_msdos $media_device ${MNT} > /dev/ttyv1 2>&1; then
431                                         error "Unable to mount $media_device"
432                                         media_device=""
433                                 else
434                                         media_type=doshd
435                                         media_device=${MNT}
436                                         media_get_possible_subdir
437                                 fi
438                         else
439                                 media_type=dosfd
440                         fi
441                 fi
442         ;;
443
444         FTP)
445                 if ! network_setup; then continue; fi
446                 if media_select_ftp_site; then
447                         media_type=ftp
448                         media_device=$ftp_path
449                 fi
450         ;;
451
452         NFS)
453                 if ! network_setup; then continue; fi
454                 title="NFS Installation Information"
455                 default_value="$nfs_path"
456                 if ! input \
457 "Please specify a machine and directory mount point for the
458 distribution you wish to load.  This must be in machine:dir
459 format (e.g. zooey:/a/FreeBSD/${DISTNAME}).  The remote
460 directory *must* be be exported to your machine (or globally)
461 for this to work!\n"; then continue; fi
462                 default_value=""
463                 if input \
464 "Do you wish to specify any options to NFS?  If you're installing
465 from a Sun 4.1.x system, you may wish to specify resvport to allow
466 installation over a priviledged port.  When using a slow ethernet
467 card or network link, rsize=4096,wsize=4096 may also prove helpful.
468 Options, if any, should be separated by commas."; then
469                         if [ "$answer" != "" ]; then
470                                 nfs_options="-o $answer"
471                         fi
472                 fi
473                 media_type=nfs
474                 nfs_path=$answer
475                 umount ${MNT} > /dev/null 2>&1
476                 if ! mount_nfs $nfs_options $nfs_path ${MNT} > /dev/ttyv1 2>&1; then
477                         error "Unable to mount $nfs_path"
478                 else
479                         message "$nfs_path mounted successfully"
480                         media_device=${MNT}
481                         media_get_possible_subdir
482                 fi
483         ;;
484
485         UFS)
486                 dialog $clear --title "User Intervention Requested" --msgbox "
487 Please mount the filesystem you wish to use somewhere convenient and
488 exit the shell when you're through.  I'll ask you for the location
489 of the distribution when we come back." -1 -1
490                 dialog --clear
491                 /stand/sh
492                 title="Please enter directory"
493                 default_value="${MNT}/bindist"
494                 if input "Ok, now give me the full pathname of the directory where you've got the distribution."; then
495                         if [ ! -f $answer/extract.sh ]; then
496                                 error "That's not a valid distribution"
497                         else
498                                 media_type=ufs
499                                 media_device=$answer
500                         fi
501                 fi
502         ;;
503         esac
504         done
505 }