2 # $NetBSD: install.sub,v 1.44 2006/04/24 19:00:30 snj Exp $
4 # Copyright (c) 1996 The NetBSD Foundation, Inc.
7 # This code is derived from software contributed to The NetBSD Foundation
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
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.
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.
32 # NetBSD installation/upgrade script - common subroutines.
34 ROOTDISK
="" # filled in below
35 VERSION
= # filled in automatically (see list)
38 ALLSETS
="base comp etc games man misc text" # default install sets
39 UPGRSETS
="base comp games man misc text" # default upgrade sets
40 THESETS
= # one of the above
42 local_sets_dir
="" # Path searched for sets by install_sets
43 # on the local filesystems
45 # decide upon an editor
46 if [ X
$EDITOR = X
]; then
47 if [ -x /usr
/bin
/vi
]; then
56 if [ "X$resp" = "X" ]; then
62 # test the first argument against the remaining ones, return succes on a match
65 if [ "$_a" = "$1" ]; then return 0; fi
72 # remove first argument from list formed by the remaining arguments
77 if [ "$_a" != "$1" ]; then
85 # read a line of data, return Nth element.
90 # optional field separator
93 -t?
*) IFS
=${1#-t}; shift;;
99 if [ "$1" = "" ]; then return; fi
104 # read a line of data, return last element. Equiv. of awk '{print $NF}'.
108 # optional field separator
111 -t?
*) IFS
=${1#-t}; shift;;
116 if [ "$1" = "" ]; then return; fi
117 while [ "$#" -gt 10 ]; do shift 10; done
122 # return first character of argument
125 while [ ${#_a} != 1 ]; do
133 if [ "$1" = "" ]; then return; fi
138 while [ "$#" -gt 10 ]; do shift 10; done
143 # return true when the directory $1 contains a set for $2...$n
150 if [ -f $_dir/${_file}.
tar.gz
]; then
153 # Try for stupid msdos convention
154 if [ -f $_dir/${_file}.tgz
]; then
157 # Try for uncompressed files
158 if [ -f $_dir/${_file}.
tar ]; then
161 # Try for split files
162 if [ -f $_dir/${_file}${VERSION}.aa
]; then
170 # spin the propeller so we don't get bored
172 sleep 1; echo -n "/\b";
173 sleep 1; echo -n "-\b";
174 sleep 1; echo -n "\\\b";
175 sleep 1; echo -n "|\b";
176 done > /dev
/tty
& echo $
!
180 # $1 is relative mountpoint
187 if [ X
$_mp != X
]; then
188 cat << __get_localdir_1
189 Note: your filesystems are mounted under the temporary mount point \"$_mp\".
190 The pathname you are requested to enter below should NOT include the \"$_mp\"
194 echo -n "Enter the pathname where the sets are stored [$_dir] "
198 # Allow break-out with empty response
199 if [ -z "$_dir" ]; then
200 echo -n "Are you sure you don't want to set the pathname? [n] "
212 if dir_has_sets
"$_mp/$_dir" $THESETS
214 local_sets_dir
="$_mp/$_dir"
217 cat << __get_localdir_2
218 The directory \"$_mp/$_dir\" does not exist, or does not hold any of the
221 echo -n "Re-enter pathname? [y] "
236 cat << \__getrootdisk_1
238 The installation program needs to know
which disk to consider
239 the root disk. Note the unit number may be different than
240 the unit number you used
in the standalone installation
246 _DKDEVS
=`md_get_diskdevs`
249 echo -n "Which disk is the root disk? "
251 if isin
$resp $_DKDEVS ; then
255 echo "The disk $resp does not exist."
261 cat << \__labelmoredisks_1
263 You may label the following disks
:
268 echo -n "Label which disk? [done] "
275 if isin
$resp $_DKDEVS ; then
279 echo "The disk $resp does not exist."
291 # Create an entry in the hosts table. If no host table
292 # exists, create one. If the IP address already exists,
294 if [ ! -f /tmp
/hosts
]; then
295 echo "127.0.0.1 localhost" > /tmp
/hosts
298 sed "/^$1 /d" < /tmp
/hosts
> /tmp
/hosts.new
299 mv /tmp
/hosts.new
/tmp
/hosts
301 if [ X
${FQDN} != X
]; then
304 echo "$1 $2 $fqdn" >> /tmp
/hosts
308 # $1 - interface name
309 # $2 - interface symbolic name
310 # $3 - interface IP address
311 # $4 - interface netmask
312 # $5 - (optional) interface link-layer medium, preceded by "media ", else ""
313 # $6 - (optional) interface link-layer directives
316 # Create a ifconfig.* file for the interface.
317 echo "inet $2 netmask $4 $5 $6" > /tmp
/ifconfig.
$1
326 # _IFS=`md_get_ifdevs`
327 _IFS
=`ifconfig -l | sed '
334 resp
="" # force at least one iteration
335 while [ "X${resp}" != X
"done" ]; do
336 cat << \__configurenetwork_1
338 You may configure the following network interfaces
(the interfaces
339 marked with
[X
] have been successfully configured
):
343 for _ifs
in $_IFS; do
344 if isin
$_ifs $_ifsdone ; then
352 echo -n "Configure which interface? [done] "
359 if isin
$_ifs $_IFS ; then
360 if configure_ifs
$_ifs ; then
361 _ifsdone
="$_ifs $_ifsdone"
364 echo "Invalid response: \"$resp\" is not in list"
374 local _interface_name
376 local _interface_mask
377 local _interface_symname
378 local _interface_extra
379 local _interface_mediumtype
380 local _interface_supported_media
386 if isin
$_interface_name `ifconfig -l -u` ; then
390 _interface_supported_media
=`ifconfig -m $_interface_name | sed -n '
391 /^[ ]*media autoselect/d
394 # get current "media" "ip" and "netmask" ("broadcast")
395 _t
=`ifconfig $_interface_name | sed -n '
396 s/^[ ]*media: [^ ]* \([^ ][^ ]*\).*/\1/p'`
398 if [ "$_t" != "manual" -a "$_t" != "media:" -a "$_t" != "autoselect" ];
400 _interface_mediumtype
=$1
403 set -- `ifconfig $_interface_name | sed -n '
406 s/--> [0-9.][0-9.]*//
415 resp
="" # force one iteration
416 while [ "X${resp}" = X
"" ]; do
417 echo -n "IP address? [$_interface_ip] "
418 getresp
"$_interface_ip"
423 resp
="" # force one iteration
424 while [ "X${resp}" = X
"" ]; do
425 echo -n "Symbolic (host) name? "
427 _interface_symname
=$resp
431 resp
="" # force one iteration
432 while [ "X${resp}" = X
"" ]; do
433 echo -n "Netmask? [$_interface_mask] "
434 getresp
"$_interface_mask"
435 _interface_mask
=$resp
438 echo "Your network interface might require explicit selection"
439 echo "of the type of network medium attached. Supported media:"
440 echo "$_interface_supported_media"
441 echo -n "Additional media type arguments (none)? [$_interface_mediumtype] "
442 getresp
"$_interface_mediumtype"
444 if [ "X${resp}" != X
"" -a "X${resp}" != Xnone
]; then
445 _interface_mediumtype
=$resp
450 echo "Your network interface might require additional link-layer"
451 echo "directives (like \`link0'). If this is the case you can enter"
452 echo "these at the next prompt."
454 echo -n "Additional link-layer arguments (none)? [$_interface_extra] "
455 getresp
"$_interface_extra"
456 if [ "X${resp}" != X
"" -a "X${resp}" != Xnone
]; then
457 _interface_extra
=$resp
460 # Configure the interface. If it
461 # succeeds, add it to the permanent
462 # network configuration info.
463 if [ $_up != "UP" ]; then
464 ifconfig
${_interface_name} down
465 if ifconfig
${_interface_name} inet \
467 netmask
${_interface_mask} \
468 ${_interface_extra} ${_m} up
; then
470 "${_interface_name}" \
471 "${_interface_symname}" \
473 "${_interface_mask}" \
475 "${_interface_extra}"
479 echo "Interface ${_interface_name} is already active."
480 echo "Just saving configuration on new root filesystem."
482 "${_interface_name}" \
483 "${_interface_symname}" \
485 "${_interface_mask}" \
487 "${_interface_extra}"
492 # Much of this is gratuitously stolen from /etc/rc.d/network.
495 # Set up the hostname.
496 if [ -f /mnt
/etc
/myname
]; then
497 hostname
=`cat /mnt/etc/myname`
498 elif [ -f /mnt
/etc
/rc.conf
];then
499 hostname
=`sh -c '. /mnt/etc/rc.conf ; echo $hostname'`
501 echo "ERROR: no /etc/myname!"
504 if [ -z "$hostname" ];then
505 echo "ERROR: hostname not set in /etc/myname or /etc/rc.conf!"
510 # configure all the interfaces which we know about.
511 if [ -f /mnt
/etc
/rc.conf
]; then
513 # assume network interface configuration style 1.2D and up
514 if [ -f /mnt
/etc
/defaults
/rc.conf
]; then
515 .
/mnt
/etc
/defaults
/rc.conf
519 if [ "$net_interfaces" != NO
]; then
520 if [ "$auto_ifconfig" = YES
]; then
523 tmp
="$net_interfaces"
525 echo -n "configuring network interfaces:"
527 eval `echo 'args=$ifconfig_'$i`
528 if [ ! -z "$args" ]; then
531 elif [ -f /mnt
/etc
/ifconfig.
$i ]; then
535 done) < /mnt
/etc
/ifconfig.
$i
536 elif [ "$auto_ifconfig" != YES
]; then
538 echo -n "/mnt/etc/ifconfig.$i missing"
539 echo -n "& ifconfig_$i not set"
540 echo "; interface $i can't be configured"
550 set -- `echo /mnt/etc/hostname*`
554 while [ $# -ge 2 ] ; do
555 shift # get rid of "hostname"
557 read af name mask bcaddr extras
560 if [ ! -n "$name" ]; then
561 echo "/etc/hostname.$1: invalid network configuration file"
565 cmd
="ifconfig $1 $af $name "
566 if [ "${dt}" = "dest" ]; then cmd
="$cmd $dtaddr"; fi
567 if [ -n "$mask" ]; then cmd
="$cmd netmask $mask"; fi
568 if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then
569 cmd
="$cmd broadcast $bcaddr";
574 ) < /mnt
/etc
/hostname.
$1
580 # set the address for the loopback interface
581 ifconfig lo0 inet localhost
583 # use loopback, not the wire
584 route add
$hostname localhost
586 # /etc/mygate, if it exists, contains the name of my gateway host
587 # that name must be in /etc/hosts.
588 if [ -f /mnt
/etc
/mygate
]; then
589 route delete default
> /dev
/null
2>&1
590 route add default
`cat /mnt/etc/mygate`
593 # enable the resolver, if appropriate.
594 if [ -f /mnt
/etc
/resolv.conf
]; then
595 _resolver_enabled
="TRUE"
596 cp /mnt
/etc
/resolv.conf
/tmp
/resolv.conf.shadow
600 echo "Network interface configuration:"
605 if [ "X${_resolver_enabled}" = X
"TRUE" ]; then
608 echo "Resolver enabled."
612 echo "Resolver not enabled."
623 # Build a script to extract valid files from a list
624 # of filenames on stdin.
625 # XXX : Can we use this on more places? Leo.
627 echo "#!/bin/sh" > /tmp
/fname_filter.sh
628 echo "while read line; do" >> /tmp
/fname_filter.sh
629 echo " case \$line in" >> /tmp
/fname_filter.sh
630 for _f
in $THESETS; do
631 echo " $_f.tar.gz|$_f.tgz|$_f.tar|$_f.${VERSION}.aa)" \
632 >> /tmp
/fname_filter.sh
633 echo ' echo -n "$line ";;' \
634 >> /tmp
/fname_filter.sh
636 echo " *) ;;" >> /tmp
/fname_filter.sh
637 echo " esac" >> /tmp
/fname_filter.sh
638 echo "done" >> /tmp
/fname_filter.sh
640 # Get several parameters from the user, and create
641 # a shell script that directs the appropriate
643 cat << \__install_ftp_1
645 This is an automated ftp-based installation process. You will be asked
646 several questions. The correct
set of commands will be placed
in a
script
647 that will be fed to
ftp(1).
650 # Get server IP address
651 resp
="" # force one iteration
652 while [ "X${resp}" = X
"" ]; do
653 echo -n "Server IP? [${_ftp_server_ip}] "
654 getresp
"${_ftp_server_ip}"
659 resp
="" # force one iteration
660 while [ "X${resp}" = X
"" ]; do
661 echo -n "Login? [${_ftp_server_login}] "
662 getresp
"${_ftp_server_login}"
663 _ftp_server_login
=$resp
667 resp
="" # force one iteration
668 while [ "X${resp}" = X
"" ]; do
674 _ftp_server_password
=$resp
677 cat << \__install_ftp_2
679 You will be asked to enter the name of the directory that contains the
680 installation sets. When you enter a
'?' you will see a listing of the
681 current directory on the server.
684 while [ -z "$_sets" ]
686 resp
="" # force one iteration
687 while [ "X${resp}" = X
"" ]; do
688 echo -n "Server directory? [${_ftp_server_dir}] "
689 getresp
"${_ftp_server_dir}"
690 if [ "X$resp" = 'X?' -a -z "$_ftp_server_dir" ]; then
694 if [ $resp != '?' ]; then
695 _ftp_server_dir
=$resp
698 # Build the basics of an ftp-script...
699 echo "#!/bin/sh" > /tmp
/ftp-script.sh
700 echo "cd /mnt" >> /tmp
/ftp-script.sh
701 echo "ftp -e -i -n $_ftp_server_ip << \__end_commands" >> \
703 echo "user $_ftp_server_login $_ftp_server_password" >> \
705 echo "bin" >> /tmp
/ftp-script.sh
706 echo "cd $_ftp_server_dir" >> /tmp
/ftp-script.sh
708 # Make a copy of this script that lists the directory
709 # contents, and use that to determine the files to get.
710 cat /tmp
/ftp-script.sh
> /tmp
/ftp-dir.sh
711 echo "nlist" >> /tmp
/ftp-dir.sh
712 echo "quit" >> /tmp
/ftp-dir.sh
713 echo "__end_commands" >> /tmp
/ftp-dir.sh
715 if [ $resp = '?' ]; then
718 _sets
=`sh /tmp/ftp-dir.sh | sh /tmp/fname_filter.sh`
721 rm -f /tmp
/ftp-dir.sh
/tmp
/fname_filter.sh
724 echo "The following sets are available for extraction:"
725 echo "(marked sets are already on the extraction list)"
729 for _f
in $_sets ; do
730 if isin
$_f $_setsdone; then
735 if [ -z "$_next" ]; then _next
=$_f; fi
741 # Get name of the file and add extraction command
743 if [ "X$_next" = "X" ]; then resp
=n
; else resp
=y
; fi
744 echo -n "Continue to add filenames [$resp]? "
746 if [ "$resp" = "n" ]; then
750 echo -n "File name [$_next]? "
752 if isin
$resp $_sets; then
753 echo "get $resp |\"pax -zr${verbose_flag}pe\"" >> \
755 _setsdone
="$resp $_setsdone"
757 echo "You entered an invalid filename."
762 echo "quit" >> /tmp
/ftp-script.sh
763 echo "__end_commands" >> /tmp
/ftp-script.sh
765 sh
/tmp
/ftp-script.sh
766 rm -f /tmp
/ftp-script.sh
767 echo "Extraction complete."
770 install_from_mounted_fs
() {
771 # $1 - directory containing installation sets
782 if ! dir_has_sets
${_dirname} $THESETS
786 echo "The directory at the mount point, \"${_dirname}\", contains: "
790 echo "Enter the subdirectory relative to the mountpoint, that"
791 echo -n "contains the savesets: [try this directory] "
793 if [ "X${resp}" != "X" ]; then
794 _dirname
=${_dirname}/$resp
797 while ! dir_has_sets
${_dirname} $THESETS; do
799 echo -n "There are no NetBSD install sets available in "
800 echo "\"${_dirname}\"."
801 echo "\"${_dirname}\" contains: "
805 echo -n "Enter subdirectory: [try other install media] "
807 if [ "X${resp}" = "X" ]; then
810 if [ ! -d ${_dirname}/${resp} ]; then
811 echo "\"${resp}\" is no directory; try again."
813 _dirname
=${_dirname}/$resp
818 for _f
in $THESETS ; do
819 if [ -f ${_dirname}/${_f}.
tar.gz
]; then
820 _sets
="$_sets ${_f}.tar.gz"
821 elif [ -f ${_dirname}/${_f}.tgz
]; then
822 _sets
="$_sets ${_f}.tgz"
823 elif [ -f ${_dirname}/${_f}.
tar ]; then
824 _sets
="$_sets ${_f}.tar"
825 elif [ -f ${_dirname}/${_f}${VERSION}.aa
]; then
826 _sets
="$_sets ${_f}${VERSION}"
831 echo "The following sets are available for extraction:"
832 echo "(marked sets have already been extracted)"
837 for _f
in $_sets ; do
838 if isin
$_f $_setsdone; then
843 if [ -z "$_next" ]; then
852 # Get the name of the file.
853 if [ "X$_next" = "X" ]; then
858 echo -n "Continue extraction [$resp]?"
860 if [ "$resp" = "n" ]; then
864 echo -n "File name(s) (or "all
") [$_next]? "
866 if [ "x$resp" = xall
]; then
871 _filename
="/${_dirname}/$_f"
874 if [ ! -f $_filename ]; then
875 if [ -f ${_filename}.aa
]; then
876 _filename
=${_filename}.
\?\?
878 echo "File $_filename does not exist. Check to make"
879 echo "sure you entered the information properly."
885 echo "Extracting the $_f set:"
888 (cd /mnt
; pax
-r${verbose_flag}pe
< $_filename)
892 (cd /mnt
; pax
-zr${verbose_flag}pe
)
895 echo "Extraction complete."
896 _setsdone
="$_f $_setsdone"
904 local _partition_range
909 # Get the cdrom device info
910 cat << \__install_cdrom_1
912 The following CD-ROM devices are installed on your system
; please
select
913 the CD-ROM device containing the partition with the installation sets
:
916 _CDDEVS
=`md_get_cddevs`
919 echo -n "Which is the CD-ROM with the installation media? [abort] "
928 if isin
$resp $_CDDEVS ; then
932 echo "The CD-ROM $resp does not exist."
940 _partition_range
=`md_get_partition_range`
941 resp
="" # force one iteration
942 while [ "X${resp}" = X
"" ]; do
943 echo -n "Partition? [a] "
951 echo "Invalid response: $resp"
952 resp
="" # force loop to repeat
957 # Ask for filesystem type
958 cat << \__install_cdrom_2
960 There are two CD-ROM filesystem types currently supported by this program
:
962 2) Berkeley Fast Filesystem
(ffs
)
965 resp
="" # force one iteration
966 while [ "X${resp}" = X
"" ]; do
967 echo -n "Which filesystem type? [cd9660] "
975 echo "Invalid response: $resp"
976 resp
="" # force loop to repeat
982 if ! mount
-t ${_fstype} -o ro \
983 /dev
/${_drive}${_partition} /mnt2
; then
984 echo "Cannot mount CD-ROM drive. Aborting."
988 install_from_mounted_fs
/mnt2
989 umount
-f /mnt2
> /dev
/null
2>&1
993 # Mount a disk on /mnt2. The set of disk devices to choose from
995 # returns 0 on failure.
998 local _partition_range
1014 if isin
$resp $_DKDEVS ; then
1018 echo "The disk $resp does not exist."
1026 _partition_range
=`md_get_partition_range`
1027 resp
="" # force one iteration
1028 while [ "X${resp}" = X
"" ]; do
1029 echo -n "Partition? [d] "
1037 echo "Invalid response: $resp"
1038 resp
="" # force loop to repeat
1043 # Ask for filesystem type
1044 cat << \__mount_a_disk_2
1046 The following filesystem types are supported
:
1049 _md_fstype
=`md_native_fstype`
1050 _md_fsopts
=`md_native_fsopts`
1051 if [ ! -z "$_md_fstype" ]; then
1052 echo " 2) $_md_fstype"
1054 _md_fstype
="_undefined_"
1056 resp
="" # force one iteration
1057 while [ "X${resp}" = X
"" ]; do
1058 echo -n "Which filesystem type? [ffs] "
1070 echo "Invalid response: $resp"
1071 resp
="" # force loop to repeat
1077 if ! mount
-t ${_fstype} -o $_fsopts \
1078 /dev
/${_drive}${_partition} /mnt2
; then
1079 echo "Cannot mount disk. Aborting."
1088 cat << \__install_disk_1
1090 Ok
, lets
install from a disk. The file-system the
install sets on may
1091 already mounted
, or we might have to mount the filesystem to get to it.
1095 echo -n "Is the file-system with the install sets already mounted? [n] "
1099 echo "What mount point are the sets located in? [] "
1101 if [ -d "$resp" ]; then
1102 install_from_mounted_fs
$resp
1104 echo "$resp: Not a directory, aborting..."
1112 cat << \__install_disk_2
1114 The following disk devices are installed on your system
; please
select
1115 the disk device containing the partition with the installation sets
:
1118 _DKDEVS
=`md_get_diskdevs`
1121 echo -n "Which is the disk with the installation sets? [abort] "
1123 if mount_a_disk
; then
1127 install_from_mounted_fs
/mnt2
1128 umount
-f /mnt2
> /dev
/null
2>&1
1132 # Get the IP address of the server
1133 resp
="" # force one iteration
1134 while [ "X${resp}" = X
"" ]; do
1135 echo -n "Server IP address? [${_nfs_server_ip}] "
1136 getresp
"${_nfs_server_ip}"
1138 _nfs_server_ip
=$resp
1140 # Get server path to mount
1141 resp
="" # force one iteration
1142 while [ "X${resp}" = X
"" ]; do
1143 echo -n "Filesystem on server to mount? [${_nfs_server_path}] "
1144 getresp
"${_nfs_server_path}"
1146 _nfs_server_path
=$resp
1148 # Determine use of TCP
1149 echo -n "Use TCP transport (only works with capable NFS server)? [n] "
1157 echo -n "Use small NFS transfers (needed when server "
1159 echo -n "has a slow network card)? [n] "
1163 _nfs_tcp
="-r 1024 -w 1024"
1174 mkdir
/mnt2
> /dev
/null
2>&1
1175 if ! mount_nfs
$_nfs_tcp ${_nfs_server_ip}:${_nfs_server_path} \
1177 echo "Cannot mount NFS server. Aborting."
1181 install_from_mounted_fs
/mnt2
1182 umount
-f /mnt2
> /dev
/null
2>&1
1188 # Get the name of the tape from the user.
1189 cat << \__install_tape_1
1191 The installation program needs to know
which tape device to use. Make
1192 sure you use a
"no rewind on close" device.
1195 _tape
=`basename $TAPE`
1196 resp
="" # force one iteration
1197 while [ "X${resp}" = X
"" ]; do
1198 echo -n "Name of tape device? [${_tape}]"
1201 _tape
=`basename $resp`
1202 TAPE
="/dev/${_tape}"
1203 if [ ! -c $TAPE ]; then
1204 echo "$TAPE does not exist or is not a character special file."
1210 # Rewind the tape device
1211 echo -n "Rewinding tape..."
1212 if ! mt rewind
; then
1213 echo "$TAPE may not be attached to the system or may not be"
1214 echo "a tape device. Aborting."
1219 # Get the file number
1220 resp
="" # force one iteration
1221 while [ "X${resp}" = X
"" ]; do
1222 echo -n "File number? "
1226 _nskip
=`expr $resp - 1`
1230 echo "Invalid file number ${resp}."
1231 resp
="" # fore loop to repeat
1236 # Skip to correct file.
1237 echo -n "Skipping to source file..."
1238 if [ "X${_nskip}" != X
"0" ]; then
1239 if ! mt fsf
$_nskip ; then
1240 echo "Could not skip $_nskip files. Aborting."
1246 cat << \__install_tape_2
1248 There are
2 different ways the
file can be stored on tape
:
1250 1) an image of a gzipped
tar file
1251 2) a standard
tar image
1254 resp
="" # force one iteration
1255 while [ "X${resp}" = X
"" ]; do
1256 echo -n "Which way is it? [1] "
1260 _xcmd
="pax -zr${verbose_flag}pe"
1264 _xcmd
="pax -r${verbose_flag}pe"
1268 echo "Invalid response: $resp."
1269 resp
="" # force loop to repeat
1272 ( cd /mnt
; dd if=$TAPE |
$_xcmd )
1274 echo "Extraction complete."
1282 # If the zoneinfo is not on the installation medium or on the
1283 # installed filesystem, set TZ to GMT and return immediatly.
1285 if [ ! -e /usr
/share
/zoneinfo
-a ! -e /mnt
/usr
/share
/zoneinfo
]; then
1289 if [ ! -d /usr
/share
/zoneinfo
]; then
1295 cat << \__get_timezone_1
1297 Select a
time zone
for your location. Timezones are represented on the
1298 system by a directory structure rooted
in "/usr/share/zoneinfo". Most
1299 timezones can be selected by entering a token like
"MET" or
"GMT-6".
1300 Other zones are grouped by continent
, with detailed zone information
1301 separated by a slash
("/"), e.g.
"US/Pacific".
1303 To get a listing of what
's available in /usr/share/zoneinfo, enter "?"
1304 at the prompts below.
1307 if [ X$TZ = X ]; then
1308 TZ=`ls -l /mnt/etc/localtime 2>/dev/null | cutlast`
1309 TZ=${TZ#/usr/share/zoneinfo/}
1312 echo -n "What timezone are you in [\`?' for list
] [$TZ]?
"
1316 echo "Timezone defaults to GMT
"
1321 ls ${_zonepath}/usr/share/zoneinfo
1325 while [ -d ${_zonepath}/usr/share/zoneinfo/$_a ]; do
1326 echo -n "There are several timezones available
"
1327 echo " within zone
'$_a'"
1328 echo -n "Select a sub-timezone
[\
`?' for list]: "
1331 "?") ls ${_zonepath}/usr/share/zoneinfo/$_a ;;
1333 if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then
1339 if [ -f ${_zonepath}/usr/share/zoneinfo/$_a ]; then
1341 echo "You have selected timezone \"$_a\"".
1344 echo "'/usr/share/zoneinfo/$_a' is not a valid timezone on this system."
1355 # Ask the user which media to load the distribution from.
1356 # Ask the user if they want verbose extraction. They might not want
1357 # it on, eg, SPARC frame buffer console.
1358 cat << \__install_sets_1
1360 It is now time to extract the installation sets onto the hard disk.
1361 Make sure the sets are either on a local device (i.e. tape, CD-ROM) or on a
1364 Would you like to see each file listed during extraction (verbose) mode?
1365 On some console hardware, such as serial consoles and Sun frame buffers,
1366 this can extend the total extraction time.
1368 echo -n "Use verbose listing for extractions? [y] "
1375 echo "Not using verbose listing."
1380 if [ -d ${Default_sets_dir:-/dev/null} ]; then
1381 if dir_has_sets $Default_sets_dir $THESETS; then
1382 local_sets_dir=$Default_sets_dir
1385 if [ "X$local_sets_dir" != "X" ]; then
1386 install_from_mounted_fs ${local_sets_dir}
1387 if [ X"$_setsdone" != X ]; then
1392 # Go on prodding for alternate locations
1393 resp="" # force at least one iteration
1394 while [ X"${resp}" = X ]; do
1395 # If _yup is not FALSE, it means that we extracted sets above.
1396 # If that's the case, bypass the menu the first time.
1397 if [ X"$_yup" = X"FALSE" ]; then
1398 echo -n "Install from (f)tp, (t)ape, (C)D-ROM, (N)FS"
1399 echo -n " or local (d)isk? "
1418 echo "Invalid response: $resp"
1423 _yup="FALSE" # So we'll ask next time
1426 # Give the user the opportunity to extract more sets. They
1427 # don't necessarily have to come from the same media.
1429 echo -n "Extract more sets? [n] "
1433 # Force loop to repeat
1452 # Now that the 'real' fstab is configured, we munge it into a 'shadow'
1453 # fstab which we'll use for mounting and unmounting all of the target
1454 # filesystems relative to /mnt. Mount all filesystems.
1457 ( while read _dev _mp _fstype _rest; do
1458 # Skip comment lines
1463 # and some filesystem types (like there are swap,kernfs,...)
1468 if [ "$_mp" = "/" ]; then
1469 echo $_dev /mnt $_fstype $_rest
1471 echo $_dev /mnt$_mp $_fstype $_rest
1473 done ) < $_fstab > $_fstab_shadow
1478 # Must mount filesystems manually, one at a time, so we can make
1479 # sure the mount points exist.
1480 # $1 is a file in fstab format
1485 ( while read line; do
1492 # If not the root filesystem, make sure the mount
1494 if [ "X{$_mp}" != X"/mnt" ]; then
1498 # Mount the filesystem. If the mount fails, exit
1499 # with an error condition to tell the outer
1501 if ! mount -v -t $_fstype -o async -o $_opt $_dev $_mp ; then
1502 # error message displated by mount
1507 if [ "X${?}" != X"0" ]; then
1508 cat << \__mount_filesystems_1
1510 FATAL ERROR: Cannot mount filesystems. Double-check your configuration
1511 and restart the installation process.
1512 __mount_filesystems_1
1519 # Unmount all filesystems and check their integrity.
1520 # Usage: [-fast] <fstab file>
1525 if [ "$1" = "-fast" ]; then
1533 if [ ! \( -f $_fstab -a -s $_fstab \) ]; then
1534 echo "fstab empty" > /dev/tty
1538 if [ $_fast = 0 ]; then
1539 echo -n "Syncing disks..."
1541 sync; sleep 4; sync; sleep 2; sync; sleep 2
1549 # maintain reverse order
1555 echo -n "Umounting filesystems... "
1556 for _mp in ${_mps}; do
1562 if [ $_fast = 0 ]; then
1565 echo "Checking filesystem integrity..."
1566 for _dev in ${_devs}; do
1576 # Check filesystem integrity.
1577 # $1 is a file in fstab format
1591 echo "Checking filesystem integrity..."
1592 for _dev in ${_devs}; do