home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec:/etc:/private/etc ; export PATH
- ARCH=`arch`
-
- abort () {
- echo "Aborting the installation"
- echo "1: Restart the installation"
- echo "2: Spawn a shell"
- echo "3: Reboot"
- }
-
- finishup () {
-
- echo "Installation is now complete."
- echo "You may: "
- until [ ! : ]
- do
- echo "1) Reboot"
- echo "2) Spawn a shell"
- echo -n "Your Choice: "
- read CHOICE
- case ${CHOICE} in
- 1) reboot
- break ;;
- 2) exec /bin/sh
- break
- ;;
- esac
- done
- }
-
- # This function will nuke the whole disk and create the 0xAB and 0xA8
- # partitions. $INSTALLDEV and $RAWINSTDEV need to be set to the
- # device to nuke, and the corresponding raw device.
- partition_disk () {
- # needs help on ppc
- echo "Partitioning disk ${INSTALLDEV}"
- echo "Warning: this will destroy all data on the disk!"
- echo -n "Continue? (y/n) "
- read CONT
-
- if [ ${CONT} != y ]; then
- abort
- fi
-
- fdisk ${RAWINSTDEV} -useBoot0 -useAllSectors -bootPlusUFS
- ;
- }
-
- # This will look for partitions on the selected disk, and
- # allow the user to select the 0xAB and 0xA8 partitions to
- # use. $INSTALLDEV needs to be set to the device to look for,
- # and $BOOTERPART and $ROOTPART will be set to the chosen
- # values upon return.
- use_partitions () {
- echo ""
- PARTS=`ls -1 ${INSTALLDEV}s*`
-
- echo "The following partitions are available:"
- for devs in ${PARTS}
- do
- echo ${devs}
- done
-
- # Only x86 needs the booter partition
- if [ "${ARCH}" == "i386" ]; then
- BOOTERPART=""
- until [[ ${BOOTERPART} != "" && -b ${BOOTERPART} ]]
- do
- echo "Which will be the booter partition?"
- read BOOTERPART
- done
-
- fi
-
- ROOTPART=""
- until [[ ${ROOTPART} != "" && -b ${ROOTPART} && ${ROOTPART} != ${BOOTERPART} ]]
- do
- echo "Which will be the root partition?"
- read ROOTPART
-
- if [ ${ROOTPART} == ${BOOTERPART} ]; then
- echo "The root partition can't be the same as the booter partition"
- fi
- done
-
- echo "Using: "
- if [ ! -z "${BOOTERPART}" ]; then
- echo "${BOOTERPART} as the booter partition"
- fi
- echo "${ROOTPART} as the root partition"
- ;
- }
-
- # This just runs fdisk interactivly on the chosen raw install device
- run_fdisk () {
- echo "Starting fdisk"
- if [ "${ARCH}" == "i386" ]; then
- fdisk ${RAWINSTDEV}
- elif [ "${ARCH}" == "ppc" ]; then
- /usr/sbin/pdisk
- fi
- ;
- }
-
- install_booter () {
- if [ "${ARCH}" == "i386" ]; then
- echo "Installing booter on ${BOOTERPART}"
- dd if=/usr/standalone/i386/boot1 of=${BOOTERPART} bs=512 count=1 >>/dev/null 2>&1
- dd if=/usr/standalone/i386/boot of=${BOOTERPART} bs=512 seek=1 >>/dev/null 2>&1
- elif [ "${ARCH}" == "ppc" ]; then
- bless -folder /mnt/System/Library/CoreServices -bootinfo /mnt/usr/standalone/ppc/bootx.bootinfo
- fi
- ;
- }
-
- install_packages () {
- echo "Creating Filesystem on ${ROOTPART}"
- if [ "${ARCH}" == "i386" ]; then
- newfs ${ROOTPART} >>/dev/null 2>&1
- mount ${ROOTPART} /mnt
- elif [ "${ARCH}" == "ppc" ]; then
- newfs_hfs -v Darwin ${ROOTPART} >> /dev/null 2>&1
- mount -t hfs ${ROOTPART} /mnt
- fi
- echo "Installing packages on ${ROOTPART}"
- cd /mnt
- /etc/install-debs /System/Installation/packages
-
- if [ -d /System/Installation/unsupported ]; then
- /etc/install-debs /System/Installation/unsupported
- fi
- /etc/install-debs /System/Installation/unsupported
-
- # If the apple_binary directory exists, install the packages in there.
- if [ -d /System/Installation/apple_binary ]; then
- for a in `ls -1 /System/Installation/apple_binary`
- do
- gnutar zxfp /System/Installation/apple_binary/${a}
- done
- fi
-
- # Both of the following two sections should go away...
-
- if [ "${ARCH}" == "i386" ]; then
- # Copy over the System.config info, since it's
- # not in a package yet.
- mkdir -p /mnt/private/Drivers/i386/System.config/
- cp /private/Drivers/i386/System.config/Default.table /mnt/private/Drivers/i386/System.config/Default.table
-
- # Thin the kernel because of bugs in boot2
- mv /mnt/mach_kernel /mnt/mach_kernel.fat
- lipo -thin i386 -output /mnt/mach_kernel /mnt/mach_kernel.fat
- fi
-
- cd /
-
- ;
- }
-
- main() {
- # Get the device the user wants to install onto.
- INSTALLDEV="novalue"
- until [[ ${INSTALLDEV} != "" && -b ${INSTALLDEV} ]]
- do
- echo "The following devices are available for installation:"
- iofindwholemedia
- echo -n "Which device would you like to install Darwin onto? "
- read INSTALLDEV
-
- if [ ${INSTALLDEV} == "shell" ]; then
- exec /bin/sh
- fi
-
- INSTALLDEV=`iofindwholemedia ${INSTALLDEV}`
-
- if [ ! -b ${INSTALLDEV} ]; then
- echo ""
- echo "${INSTALLDEV} doesn't exist, please enter one of the listed devices."
- echo ""
- fi
- done
-
- RAWINSTDEV=`echo ${INSTALLDEV} | sed 's/disk/rdisk/'`
-
- if [ "${ARCH}" == "i386" ]; then
- if [ `fdisk ${RAWINSTDEV} -isDiskPartitioned` == "Yes" ]; then
- echo ""
- echo "For partitioning the disk, you have the following choices:"
- until [ ! : ]
- do
- echo "1) Auto-partition the disk (Destroys all disk contents)"
- echo "2) Manually partition the disk using fdisk"
- echo "3) Use existing partitions"
- echo -n "Choice: "
- read ANSWER
- case ${ANSWER} in
- 1) partition_disk
- # Don't ask which to use, since we already know.
- BOOTERPART="${INSTALLDEV}s1"
- ROOTPART="${INSTALLDEV}s2"
- break
- ;;
- 2) run_fdisk
- use_partitions
- break
- ;;
- 3) use_partitions
- break
- ;;
- esac
- done
- else
- echo ""
- echo "For partitioning the disk, you have the following choices:"
- until [ ! : ]
- do
- echo "1) Auto-partition the disk (Destroys all disk contents)"
- echo "2) Manually partition the disk using fdisk"
- echo -n "Choice: "
- read ANSWER
- case ${ANSWER} in
- 1) partition_disk
- # Don't ask which to use, since we already know.
- BOOTERPART="${INSTALLDEV}s1"
- ROOTPART="${INSTALLDEV}s2"
- break
- ;;
- 2) run_fdisk
- use_partitions
- break
- ;;
- esac
- done
- fi
- elif [ "${ARCH}" == "ppc" ]; then
- until [ ! : ]
- do
- echo "Which partition would you like to install into: "
- i=1
- for slice in `ls ${INSTALLDEV}s*`
- do
- slice_name=`pdisk ${RAWINSTDEV} -partitionName ${i}`
- slice_type=`pdisk ${RAWINSTDEV} -partitionType ${i}`
- echo "${i}) ${slice} ${slice_type} ${slice_name}"
- i=`expr ${i} + 1`
- done
- echo -n "Your choice: "
- read ANSWER
-
- if [ -b "${INSTALLDEV}s${ANSWER}" ]; then
- ROOTPART="${INSTALLDEV}s${ANSWER}"
- break;
- fi
- done
- fi
- install_packages
- install_booter
- umount ${ROOTPART}
- finishup
- ;
- }
-
- # Set the erase character properly
- # This is only for telnet consoles...
- #stty erase
-
- # Ignore ^C
- #trap "" 2
-
- main
-
- exit
-