+ *)
+ return 2
+ ;;
+ esac
+fi
+
+
+# *** CAVEAT ***
+# $OPSYSTEM installs at the end of the disk. If the
+# beginning of the disk is free but not the end, install fails!
+
+# Assume `fdisk -u' to add $OPSYSTEM in last unused partition for remaining cases
+opsys_part=${unused_last_part}
+RUN_FDISK="fdisk -u"
+mb_sect=`expr 1024 \* 1024 / $bytes_per_sect`
+disk_minimum=`expr $DISKMIN \* $mb_sect`
+
+# Case IV: No room (at end of disk) for mininal install
+disk_remaining=`expr $disksize - $extent_max`
+if [ $disk_remaining -lt $disk_minimum ]; then
+ echo
+ echo "Not enough space ($DISKMIN Mb) at end of disk to install $OPSYSTEM."
+ echo -n "Install FreeBSD and overwrite the entire disk? [n] "
+ read resp junk
+ case "$resp" in
+ y*|Y*)
+ # don't use first cylinder!
+ opsys_off=1
+ cyls_per_opsys=`expr $cyls_per_disk - 1`
+ opsys_part=${unused_last_part}
+ RUN_FDISK="overwrite"
+ ;;
+ *)
+ echo
+ echo "WARNING: To install ${OPSYSTEM}, you're on your own in figuring"
+ echo "out where on the disk it will fit without overwriting another"
+ echo "partition..."
+ # Set defaults assuming there is only one partition at end of disk
+ eval start=\$start${extent_max_part}
+ # don't use first cylinder!
+ opsys_off=1
+ cyls_per_opsys=`expr $start / $cylindersize - 1`
+ ;;
+ esac
+ return 0
+fi
+
+# Case V: Room for $OPSYSTEM and partition data okay
+opsys_off=`expr $extent_max / $cylindersize`
+opsys_extent=`expr $opsys_off \* $cylindersize`
+[ $opsys_extent -lt $extent_max ] && opsys_off=`expr $opsys_off + 1`
+cyls_per_opsys=`expr $cyls_per_disk - $opsys_off`
+return 0
+}
+
+put_fdisk_data() {
+start=$root_offset
+size=$partition
+
+if [ "$RUN_FDISK" = "overwrite" ]; then
+ # How do you overwrite without explicitly editing each entry?
+ (
+ echo y
+ echo $cyls_per_disk
+ echo $tracks_per_cyl
+ echo $sects_per_track
+ echo y
+ ) >fdisk.script
+ i=0
+ n=`expr ${part_cnt:-4} - 1`
+ while [ $i -lt $n ]; do
+ echo y
+ echo 0
+ echo 0
+ echo 0
+ echo n
+ echo y
+ i=`expr $i + 1`
+ done >>fdisk.script
+ ( echo y
+ echo ${OPSYSID}
+ echo ${start}
+ echo ${size}
+ echo n
+ echo y
+ echo y
+ echo ${n}
+ echo y
+ echo y
+ ) >>fdisk.script
+ fdisk -u <fdisk.script >/dev/null 2>&1
+elif [ "$RUN_FDISK" ]; then
+ $RUN_FDISK -${opsys_part:-${unused_last_part:-3}} <<-EOF >/dev/null 2>&1
+ y
+ $cyls_per_disk
+ $tracks_per_cyl
+ $sects_per_track
+ y
+ y
+ ${OPSYSID}
+ ${start}
+ ${size}
+ n
+ y
+ y
+ ${opsys_part:-${unused_last_part:-3}}
+ y
+ y
+ EOF
+fi
+
+}
+
+echo "Welcome to ${OPSYSTEM}."
+echo
+echo "This program is designed to help put ${OPSYSTEM} on a hard disk with"
+echo "at least $DISKMIN Megabytes of free space."
+echo
+echo "If other operating systems are already on the disk, ${OPSYSTEM}"
+echo "should be able to install alongside them. Otherwise, if the disk"
+echo "is being installed for the first time, it would probably be useful"
+echo "to have the disk's hardware manual, the installation notes, and a"
+echo "calculator handy."
+echo
+echo "As with anything which modifies a hard drive's contents, this"
+echo "program can cause SIGNIFICANT data loss, and we strongly recommend"
+echo "making sure that the hard drive is backed up before going further with"
+echo "the installation process."
+echo
+echo -n "Proceed with installation? [y] "
+read resp junk
+resp=${resp:-y}
+case "$resp" in
+y*|Y*)
+ echo
+ echo "Cool! Let's get to it..."
+ echo
+ echo "If a mistake is made along the way, don't bail out."
+ echo "At the end, you have the option to redo the configuration."
+ echo "If you really must quit at some point, type <CTRL>+C and"
+ echo "enter \`halt' at the command prompt, \`#'."
+ ;;
+*)
+ echo
+ echo "OK, then. Enter \`halt' to halt the machine."
+ echo "Once the machine has halted, remove the floppy,"
+ echo "and press any key to reboot."
+ exit
+ ;;