3 # instdist - Install a distribution from some sort of media.
5 # Written: November 11th, 1994
6 # Copyright (C) 1994 by Jordan K. Hubbard
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!).
13 # $Id: instdist.sh,v 1.40 1994/12/02 21:15:19 jkh Exp $
15 if [ "${_INSTINST_SH_LOADED_}" = "yes" ]; then
18 _INSTINST_SH_LOADED_=yes
21 # Grab the miscellaneous functions.
24 # Set the initial state for media installation.
36 # Set the installation media to undefined.
47 # Set the location of our temporary unpacking directory.
50 TITLE="Choose temporary directory"
51 DEFAULT_VALUE="${TMPDIR}"
53 "Please specify the name of a directory containing enough free
54 space to hold the temporary files for this distribution. At
55 minimum, a binary distribution will require around 21MB of
56 temporary space. At maximum, a srcdist may take 30MB or more.
57 If the directory you specify does not exist, it will be created
58 for you. If you do not have enough free space to hold both the
59 packed and unpacked distribution files, consider using the NFS
60 or CDROM installation methods as they require no temporary
61 storage."; then return 1; fi
69 if ! cd ${TMPDIR} > /dev/ttyv1 2>&1; then
70 error "No such file or directory for ${TMPDIR}, sorry! Please fix this and try again."
78 if [ -d ${TMPDIR}/${MEDIA_DISTRIBUTION} ]; then
79 if dialog --title "Delete contents?" --yesno \
80 "Do you wish to delete ${TMPDIR}/${MEDIA_DISTRIBUTION}?" -1 -1; then
81 rm -rf ${TMPDIR}/${MEDIA_DISTRIBUTION}
84 if dialog --title "Delete contents?" --yesno \
85 "Do you wish to delete the contents of ${TMPDIR}?" -1 -1; then
91 media_select_ftp_site()
93 dialog --title "Please specify an ftp site" --menu \
94 "FreeBSD is distributed from a number of sites on the Internet.\n\
95 Please select the site closest to you or \"other\" if you'd like\n\
96 to specify another choice. Also note that not all sites carry\n\
97 every possible distribution! Distributions other than the basic\n\
98 binary set are only guaranteed to be available from the Primary site." \
100 "Primary" "ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}" \
101 "U.S-2" "ftp://ftp.dataplex.net/pub/FreeBSD/${DISTNAME}" \
102 "U.S-3" "ftp://kryten.atinc.com/pub/FreeBSD/${DISTNAME}" \
103 "U.S-4" "ftp://ref.tfs.com/pub/FreeBSD/${DISTNAME}" \
104 "Holland" "ftp://ftp.nl.net:/pub/os/FreeBSD/${DISTNAME}" \
105 "Israel" "ftp://orgchem.weizmann.ac.il/pub/FreeBSD-${DISTNAME}" \
106 "Taiwan" "ftp://netbsd.csie.nctu.edu.tw/pub/FreeBSD/${DISTNAME}" \
107 "Australia" "ftp://ftp.physics.usyd.edu.au/FreeBSD/${DISTNAME}" \
108 "France" "ftp://ftp.ibp.fr/pub/FreeBSD/${DISTNAME}" \
109 "Finland" "ftp://nic.funet.fi:/pub/unix/FreeBSD/${DISTNAME}" \
110 "Russia" "ftp://ftp.kiae.su/FreeBSD/${DISTNAME}" \
111 "Japan" "ftp://ftp.sra.co.jp/pub/os/FreeBSD/distribution/${DISTNAME}" \
112 "Japan-2" "ftp://ftp.mei.co.jp/free/PC-UNIX/FreeBSD/${DISTNAME}" \
113 "Japan-3" "ftp://ftp.waseda.ac.jp/pub/FreeBSD/${DISTNAME}" \
114 "Japan-4" "ftp://ftp.pu-toyama.ac.jp/pub/FreeBSD/${DISTNAME}" \
115 "Japan-5" "ftp://ftpsv1.u-aizu.ac.jp/pub/os/FreeBSD/${DISTNAME}" \
116 "other" "None of the above. I want to specify my own." \
117 2> ${TMP}/menu.tmp.$$
119 ANSWER=`cat ${TMP}/menu.tmp.$$`
120 rm -f ${TMP}/menu.tmp.$$
121 if ! handle_rval ${RETVAL}; then return 1; fi
123 Primary) FTP_PATH="ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}" ;;
124 U.S-2) FTP_PATH="ftp://ftp.dataplex.net/pub/FreeBSD/${DISTNAME}" ;;
125 U.S-3) FTP_PATH="ftp://kryten.atinc.com/pub/FreeBSD/${DISTNAME}" ;;
126 U.S-4) FTP_PATH="ftp://ref.tfs.com/pub/FreeBSD/${DISTNAME}" ;;
127 Holland) FTP_PATH="ftp://ftp.nl.net:/pub/os/FreeBSD/${DISTNAME}" ;;
128 Israel) FTP_PATH="ftp://orgchem.weizmann.ac.il/pub/FreeBSD-${DISTNAME}" ;;
129 Taiwan) FTP_PATH="ftp://netbsd.csie.nctu.edu.tw/pub/FreeBSD/${DISTNAME}" ;;
130 Australia) FTP_PATH="ftp://ftp.physics.usyd.edu.au/FreeBSD/${DISTNAME}" ;;
131 France) FTP_PATH="ftp://ftp.ibp.fr/pub/FreeBSD/${DISTNAME}" ;;
132 Finland) FTP_PATH="ftp://nic.funet.fi:/pub/unix/FreeBSD/${DISTNAME}" ;;
133 Japan) FTP_PATH="ftp://ftp.sra.co.jp/pub/os/FreeBSD/distribution/${DISTNAME}" ;;
134 Japan-2) FTP_PATH="ftp://ftp.mei.co.jp/free/PC-UNIX/FreeBSD/${DISTNAME}" ;;
135 Japan-3) FTP_PATH="ftp://ftp.waseda.ac.jp/pub/FreeBSD/${DISTNAME}" ;;
136 Japan-4) FTP_PATH="ftp://ftp.pu-toyama.ac.jp/pub/FreeBSD/${DISTNAME}" ;;
137 Japan-5) FTP_PATH="ftp://ftpsv1.u-aizu.ac.jp/pub/os/FreeBSD/${DISTNAME}" ;;
138 Russia) FTP_PATH="ftp://ftp.kiae.su/FreeBSD/${DISTNAME}" ;;
140 TITLE="FTP Installation Information"
141 DEFAULT_VALUE="${FTP_PATH}"
143 "Please specify the machine and directory location of the
144 distribution you wish to load. This should be either a \"URL style\"
145 specification (e.g. ftp://ftp.freeBSD.org/pub/FreeBSD/...) or simply
146 the name of a host to connect to. If only a host name is specified,
147 the installation assumes that you will properly connect and \"mget\"
148 the files yourself."; then return 1; fi
156 if [ -f do_cksum.sh ]; then
157 message "Verifying checksums for distribution. Please wait!"
158 if sh ./do_cksum.sh; then
159 if [ -f extract.sh ]; then
160 message "Extracting ${MEDIA_DISTRIBUTION} distribution. Please wait!"
161 if [ -f ./is_interactive ]; then
164 sh ./extract.sh < /dev/ttyv1 > /dev/ttyv1 2>&1
166 dialog --title "Extraction Complete" --msgbox "Please press return to continue" -1 -1
168 error "No installation script found!"
171 error "Checksum error(s) found. Please check media!"
174 error "Improper distribution. No checksum script found!"
181 case ${MEDIA_TYPE} in
183 if ! cd ${MEDIA_DEVICE}/${MEDIA_DISTRIBUTION} > /dev/ttyv1 2>&1; then
184 error "Unable to cd to ${MEDIA_DEVICE}/${MEDIA_DISTRIBUTION} directory."
194 if ! media_set_tmpdir; then return; fi
195 if ! media_cd_tmpdir; then return; fi
196 if dialog --title "Please mount tape for ${MEDIA_DEVICE}." \
197 --yesno "Please enter the next tape and select\n<Yes> to continue or <No> if finished" -1 -1; then
198 message "Loading distribution from ${MEDIA_DEVICE}.\nUse ALT-F2 to see output, ALT-F1 to return."
199 if [ "${MEDIA_DEVICE}" = "ftape" ]; then
200 progress "${FT_CMD} | ${TAR_CMD} ${TAR_FLAGS} -"
201 ${FT_CMD} | ${TAR_CMD} ${TAR_FLAGS} - > /dev/ttyv1 2>&1
203 progress "${TAR_CMD} ${TAR_FLAGS} ${MEDIA_DEVICE}"
204 ${TAR_CMD} ${TAR_FLAGS} ${MEDIA_DEVICE} > /dev/ttyv1 2>&1
207 if [ -d ${MEDIA_DISTRIBUTION} ]; then cd ${MEDIA_DISTRIBUTION}; fi
213 if ! media_set_tmpdir; then return; fi
214 if ! media_cd_tmpdir; then return; fi
216 progress "Preparing to extract from DOS floppies"
217 while [ "${COPYING}" = "yes" ]; do
218 progress "Asking for DOS diskette"
219 if dialog --title "Insert distribution diskette" \
220 --yesno "Please enter the next diskette and select\n<Yes> to continue or <No> if finished" -1 -1; then
221 umount ${MNT} > /dev/null 2>&1
222 if ! mount_msdos -o ro ${MEDIA_DEVICE} ${MNT}; then
223 error "Unable to mount floppy! Please correct."
225 message "Loading distribution from ${MEDIA_DEVICE}.\nUse ALT-F2 to see output, ALT-F1 to return."
226 ( ${TAR_CMD} -cf - -C ${MNT} . | ${TAR_CMD} -xvf - ) >/dev/ttyv1 2>&1
239 if ! media_set_tmpdir; then return; fi
240 if ! media_cd_tmpdir; then return; fi
241 if ! echo ${MEDIA_DEVICE} | grep -q -v 'ftp://'; then
242 message "Fetching distribution using ncftp.\nUse ALT-F2 to see output, ALT-F1 to return."
243 if ! ncftp ${MEDIA_DEVICE}/${MEDIA_DISTRIBUTION}/* < /dev/null > /dev/ttyv1 2>&1; then
244 error "Couldn't fetch ${MEDIA_DISTRIBUTION} distribution from\n${MEDIA_DEVICE}!"
260 media_select_distribution()
262 MEDIA_DISTRIBUTION=""
263 while [ "${MEDIA_DISTRIBUTION}" = "" ]; do
265 dialog --title "Please specify a distribution to load" \
267 "FreeBSD is separated into a number of distributions for ease of\n\
268 installation. With repeated passes through this screen, you'll be\n\
269 given the chance to load one or all of them. Mandatory distributions\n\
270 MUST be loaded! Please also note that the secrdist is NOT FOR EXPORT\n\
271 from the U.S. Please don't endanger U.S. ftp sites by getting it\n\
272 illegally, thanks! When finished, select <Cancel>." \
274 "?diskfree" "How much disk space do I have free?" \
275 "bindist" "Binary base files (mandatory - ${BINSIZE})" \
276 "games" "Games and other frivolities (optional - ${GAMESIZE})" \
277 "manpages" "Manual pages (optional - ${MANSIZE})" \
278 "proflibs" "Profiled libraries (optional - ${PROFSIZE})" \
279 "dict" "Spelling checker dictionary files (optional - ${DICTSIZE})" \
280 "srcdist" "Sources for everything but DES (optional - ${SRCSIZE})" \
281 "secrdist" "DES encryption code (and sources) (optional - ${SECRSIZE})" \
282 "compat1xdist" "FreeBSD 1.x binary compatability (optional - ${COMPATSIZE})" \
283 "XFree86-3.1" "The XFree86 3.1 distribution (optional - ${X11SIZE})" \
284 2> ${TMP}/menu.tmp.$$
286 MEDIA_DISTRIBUTION=`cat ${TMP}/menu.tmp.$$`
287 rm -f ${TMP}/menu.tmp.$$
288 if ! handle_rval ${RETVAL}; then return 1; fi
289 if [ "${MEDIA_DISTRIBUTION}" = "?diskfree" ]; then
290 if df -k > ${TMP}/df.out; then
291 dialog --title "How much free space do I have?" \
292 --textbox ${TMP}/df.out 15 76
294 error "Couldn't get disk usage information! :-("
296 MEDIA_DISTRIBUTION=""
301 media_get_possible_subdir()
303 if [ -f ${MNT}/${MEDIA_DISTRIBUTION}/extract.sh ]; then return; fi
304 DEFAULT_VALUE="${DISTRIB_SUBDIR}"
305 TITLE="Distribution Subdirectory"
307 "If the distributions are in a subdirectory of the mount point,
308 please enter it here (no leading slash - it should be relative
309 to the mount point). The directory you enter should be the
310 *parent* directory of any distribution subdirectories."; then
311 if [ "${ANSWER}" != "" ]; then
312 MEDIA_DEVICE=${MEDIA_DEVICE}/${ANSWER}
313 DISTRIB_SUBDIR=${ANSWER}
320 # Get values into $MEDIA_TYPE and $MEDIA_DEVICE. Call network initialization
324 while [ "${MEDIA_DEVICE}" = "" ]; do
326 dialog --title "Installation From" \
328 "Before installing a distribution, you need to chose and/or configure\n\
329 a method of installation. Please pick from one of the following options.\n\
330 If none of the listed options works for you, then your best bet may be to\n\
331 simply hit ESC twice to get a subshell and proceed manually on your own.\n\
332 If you are already finished with the installation process, select cancel\n\
333 to proceed." -1 -1 7 \
334 "?Kern" "Please show me the kernel boot messages again!" \
335 "Tape" "Load distribution from SCSI, QIC-02 or floppy tape" \
336 "CDROM" "Load distribution from SCSI or Mitsumi CDROM" \
337 "DOS" "Load from DOS floppies or a DOS hard disk partition" \
338 "FTP" "Load distribution using FTP" \
339 "UFS" "Load the distribution from existing UFS partition" \
340 "NFS" "Load the distribution over NFS" 2> ${TMP}/menu.tmp.$$
342 CHOICE=`cat ${TMP}/menu.tmp.$$`
343 rm -f ${TMP}/menu.tmp.$$
344 if ! handle_rval ${RETVAL}; then return 1; fi
348 if dmesg > ${TMP}/dmesg.out; then
349 dialog --title "Kernel boot message output" \
350 --textbox ${TMP}/dmesg.out 22 76
352 error "Couldn't get dmesg information! :-("
357 dialog --title "Choose Tape Type" --menu \
358 "Which type of tape drive do you have attached to your \n\
359 system? FreeBSD supports the following types:\n" -1 -1 3 \
360 "SCSI" "SCSI tape drive attached to supported SCSI controller" \
361 "QIC-02" "QIC-02 tape drive (Colorado Jumbo, etc)" \
362 "floppy" "Floppy tape drive (QIC-40/QIC-80)" 2> ${TMP}/menu.tmp.$$
364 CHOICE=`cat ${TMP}/menu.tmp.$$`
365 rm -f ${TMP}/menu.tmp.$$
366 if ! handle_rval ${RETVAL}; then continue; fi
370 MEDIA_DEVICE=/dev/rst0
374 MEDIA_DEVICE=/dev/rwt0
384 dialog --title "Choose CDROM Type" --menu \
385 "Which type of CDROM drive do you have attached to your \n\
386 system? FreeBSD supports the following types:\n" -1 -1 2 \
387 "SCSI" "SCSI CDROM drive attached to supported SCSI controller" \
388 "Mitsumi" "Mitsumi CDROM drive" \
389 2> ${TMP}/menu.tmp.$$
391 CHOICE=`cat ${TMP}/menu.tmp.$$`
392 rm -f ${TMP}/menu.tmp.$$
393 if ! handle_rval ${RETVAL}; then continue; fi
397 MEDIA_DEVICE=/dev/cd0a
400 MEDIA_DEVICE=/dev/mcd0a
403 umount ${MNT} > /dev/null 2>&1
404 if ! mount_cd9660 ${MEDIA_DEVICE} ${MNT} > /dev/ttyv1 2>&1; then
405 error "Unable to mount ${MEDIA_DEVICE} on ${MNT}"
409 media_get_possible_subdir
415 DEFAULT_VALUE="/dev/fd0"
417 "Please specify the device pointing at your DOS partition or
418 floppy media. For a hard disk, this might be something like
419 /dev/wd0h or /dev/sd0h (as identified in the disklabel editor).
420 For the "A" floppy drive, it's /dev/fd0, for the "B" floppy
421 drive it's /dev/fd1\n"; then
422 MEDIA_DEVICE=${ANSWER}
423 if echo ${MEDIA_DEVICE} | grep -q -v fd; then
424 umount ${MNT} > /dev/null 2>&1
425 if ! mount_msdos ${MEDIA_DEVICE} ${MNT} > /dev/ttyv1 2>&1; then
426 error "Unable to mount ${MEDIA_DEVICE}"
431 media_get_possible_subdir
442 if ! network_setup; then continue; fi
443 if media_select_ftp_site; then
445 MEDIA_DEVICE=${FTP_PATH}
451 if ! network_setup; then continue; fi
452 TITLE="NFS Installation Information"
453 DEFAULT_VALUE="${NFS_PATH}"
455 "Please specify a machine and directory mount point for the
456 distribution you wish to load. This must be in machine:dir
457 format (e.g. zooey:/a/FreeBSD/${DISTNAME}). The remote
458 directory *must* be be exported to your machine (or globally)
459 for this to work!\n"; then continue; fi
462 DEFAULT_VALUE="${NFS_OPTIONS}"
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 \`-o resvport' to send
466 NFS requests over a privileged port (use this if you get nasty
467 \`\`credential too weak'' errors from the server). When using a slow
468 ethernet card or network link, \`-o -r=1024,-w=1024' may also prove helpful.
469 Options, if any, should be separated by commas."; then
470 if [ "${ANSWER}" != "" ]; then
471 NFS_OPTIONS="${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}"
479 message "${NFS_PATH} mounted successfully"
481 media_get_possible_subdir
487 dialog --title "User Intervention Requested" --msgbox "
488 Please mount the filesystem you wish to use somewhere convenient and
489 exit the shell when you're through. I'll ask you for the location
490 of the distribution's parent directory when we come back." -1 -1
493 TITLE="Please enter directory"
494 DEFAULT_VALUE="${MNT}"
495 if input "Ok, now give me the full pathname of the parent directorys for the distribution(s)."; then
497 MEDIA_DEVICE=${ANSWER}