Apple Enterprise - NeXTanswers Support Archive
Enterprise
[Index]
[Download]


Search NeXTanswers for:

 #!/bin/sh -u
#
# CD-ROM Software Installation Procedure
#
# Copyright (C) 1994 by NeXT Computer, Inc.  All rights reserved.
#
# This script is invoked automatically when booted from a CD-ROM.
# Trying to run it directly will probably not do what you expect.
#
# This script has been modified starting at line 422. Is is NeXTanser
# document #2085. See NeXTanswer 2084_NetInstalling_with_Additional_Drivers
# for information on the use of this script
#
clear() {
   echo -n "\f"
}

(
# Exit with status 1 if we get a SIGINT (from, e.g., a ^C being typed).
trap "exit 1" 2

. /.profile

# Check to be sure we're running from a CD-ROM

CDDIR=${ROOT}/NextCD

if [ ! -d ${CDDIR} ]; then 
    echo
    echo "This program is for installing NEXTSTEP on a hard disk when the"
    echo "NEXTSTEP CD-ROM is the startup disk.  Since the NEXTSTEP CD-ROM"
    echo "isn't the startup disk, you can't use this program."
    exit 1
fi

ROOT=
export ROOT

# In case we had a custom file
CDIS_DIR=${ROOT}/${CDDIR}/CDIS

AWK=${ROOT}/bin/awk
ARCH=`${ROOT}/usr/bin/arch`
CHECKFLOP=${CDIS_DIR}/checkflop
CHMOD=${ROOT}/bin/chmod
CAT=${ROOT}/bin/cat
CP=${ROOT}/bin/cp
DISK=${ROOT}/usr/etc/disk
DITTO=${CDIS_DIR}/ditto
EXPR=${ROOT}/bin/expr
FINDROOT=${CDIS_DIR}/findroot
FDISK=${ROOT}/usr/etc/fdisk
GREP=${ROOT}/bin/grep
HALT=${ROOT}/usr/etc/halt
ITAR=${ROOT}/NextAdmin/Installer.app/installer_bigtar
LOCALECHO=${CDIS_DIR}/localecho
LN=${ROOT}/bin/ln
MINSIZE=75
MKDIRS=${ROOT}/bin/mkdirs
MKFILE=${ROOT}/usr/etc/mkfile
MOUNT=${ROOT}/usr/etc/mount
MV=${ROOT}/bin/mv
PICKDISK=${CDIS_DIR}/pickdisk
REBOOT=${ROOT}/usr/etc/reboot
RM=${ROOT}/bin/rm
SED=${ROOT}/bin/sed
STTY=${ROOT}/bin/stty
SWAPON=${ROOT}/usr/etc/mach_swapon
SYNC=${ROOT}/bin/sync
SYSCONFIG=${CDIS_DIR}/sysconfig
TABLE=${CDIS_DIR}/table
TAR=${ROOT}/usr/bin/gnutar
HD=/private/tmp/mnta
FD=/private/tmp/mntb
VERFILE=${ROOT}/usr/lib/NextStep/software_version
ZCAT=${ROOT}/usr/ucb/zcat

# Clean up output
${STTY} -tabs

# check software_version file
echo -n "NEXTSTEP Release "
realversion=`$AWK 'NR==1{print $1}' $VERFILE`
echo $realversion
version=`$AWK 'NR==1{print $1}' $VERFILE | $SED 's/^[\.0-9]*//' `

LANGUAGE=`${SYSCONFIG} Language`
if [ "${LANGUAGE}" = "" -o "${LANGUAGE}" = "No language selected" ]
then
    reply=""
    while [ -z "$reply" ]
    do
	clear
	echo
	echo "Type 1 to use the English language and USA keyboard while installing NEXTSTEP."
	echo
	echo "Tapez 2 pour installer NEXTSTEP avec un clavier et des messages francais."
	echo
	echo "Eingabe 3 fuer NEXTSTEP-Installation mit deutscher Sprache und Tastatur."
	echo
	echo "Premi 4 per installare NEXTSTEP usando lingua italiana e tastiera italiana."
	echo
	echo "Pulse 5 para usar el idioma y el teclado espanol en la instalacion de NEXTSTEP."
	echo
	echo "Skriv 6 for att anvanda svenska/svenskt tangentbord vid installation av NEXTSTEP."
        echo
	echo -n "---> "
	read reply
	case "$reply" in
	1)	LANGUAGE=English
		break;;
	2)	LANGUAGE=French
		break;;
	3)	LANGUAGE=German
		break;;
	4)	LANGUAGE=Italian
		break;;
	5)	LANGUAGE=Spanish
		break;;
	6)	LANGUAGE=Swedish
		break;;
	*)	reply=""
		clear
		continue;;
	esac
    done
fi

# Let localecho know what our language is...
export LANGUAGE

reply=""
while [ -z "$reply" ]
do
   clear
   ${LOCALECHO} BOOT_DISK
   echo

   ${PICKDISK} 0
   numdisks=$?
   
   if [ $numdisks = 255 ]
   then
	    ${LOCALECHO} INSTALLFAILED
	    echo
	    ${LOCALECHO} QUITTING
	    ${HALT} -e
   fi
   echo
   ${LOCALECHO} WHICH_DISK
   echo
   echo -n "---> "
   read reply
   if [ "$reply" = 1 -o "$reply" = 2 ]
   then
      continue
   else
      reply=""
      continue
   fi
done

if [ "$reply" = 2 ]
then
   reply=""
   while [ -z "$reply" ]
   do
      clear
      ${LOCALECHO} AVAILABLE_DISKS
      echo

      ${PICKDISK}
      numdisks=$?

      if [ $numdisks = 255 ]
      then
               ${LOCALECHO} INSTALLFAILED
               echo
               ${LOCALECHO} QUITTING
               ${HALT} -e
      fi
      echo
      ${LOCALECHO} ALL_DISKS
      echo
      echo -n "---> "
      read reply
      if [ "$reply" -ge 1 -a "$reply" -le "$numdisks" ]
      then
         continue
      else
         reply=""
         continue
      fi
   done
fi

disknum=$reply
diskie=`${PICKDISK} ${disknum}`

rawdisk=/dev/r${diskie}
livedisk=`echo $rawdisk | ${SED} s/a/h/`

if [ "${ARCH}" = "i386" ]; then
   reply=""
   while [ -z "$reply" ]
   do
      ispartitioned=`${FDISK} $livedisk -isDiskPartitioned`
      disksize=`${FDISK} $livedisk -diskSize`
      if [ $ispartitioned = "Yes" ]
      then
	 currentsize=`${FDISK} $livedisk -installSize`
	 freesize=`${FDISK} $livedisk -freeSpace`
	 esize=`${FDISK} $livedisk -sizeofExtended`
      else
	 currentsize=0
	 freesize=0
	 esize=0
      fi
      choices=2
      freenum=0
      enum=0
      currentnum=0
      if [ $currentsize -ge $MINSIZE -a $currentsize -ne $disksize ]
      then
	 choices=`$EXPR $choices + 1`
	 currentnum=$choices
      fi
      if [ $currentnum -eq 0 -a $freesize -ge $MINSIZE -a $freesize -ne $disksize ]
      then
	 choices=`$EXPR $choices + 1`
	 freenum=$choices
      fi
      if [ $currentnum -eq 0 -a $esize -ge $MINSIZE ]
      then
	 choices=`$EXPR $choices + 1`
	 enum=$choices
      fi
      choices=`$EXPR $choices + 1`
      
      clear
      eval `${LOCALECHO} FDISK_MENU1`
      eval `${LOCALECHO} FDISK_MENU2`
      if [ $currentnum -ne 0 ]
      then
	 eval `${LOCALECHO} FDISK_MENU3`
      fi
      if [ $freenum -ne 0 ]
      then
	 eval `${LOCALECHO} FDISK_MENU4`
      fi
      if [ $enum -ne 0 ]
      then
	 eval `${LOCALECHO} FDISK_MENU5`
      fi
      eval `${LOCALECHO} FDISK_MENU6`

      echo
      echo -n "---> "
      read reply
      if [ "$reply" -ge 1 -a "$reply" -le $choices ]
      then
	 echo
	 case "${reply}" in
	       1) 		FDISK_FLAGS="-removePartitioning" ;;
	       2) 		${LOCALECHO} -q HOW_MUCH
			      read resp2
                              reply=""
			      newsize=`${EXPR} $disksize - $resp2`
                              if [ $? != 0 ]; then
  			         continue
			      fi
                              if [ $newsize -gt $MINSIZE ]; then
				 FDISK_FLAGS="-dosPlusNeXT ${resp2}"
			      else
				 ${LOCALECHO} TOO_SMALL
				 continue
			      fi ;;
	       $currentnum)	continue ;;
	       $freenum)	FDISK_FLAGS="-setAvailableToNeXT" ;;
	       $enum)		resp2=`${FDISK} $livedisk -sizeofExtended`
			      if [ $resp2 -gt $MINSIZE ]; then
				 FDISK_FLAGS="-setExtendedToNeXT"
			      else
				 ${LOCALECHO} TOO_SMALL
				 reply=""
				 continue
			      fi ;;
	       $choices)	${FDISK} $livedisk
			      reply=""
			      continue ;;
	       *)		reply=""
			      continue ;;
	 esac
   
	 ${FDISK} $livedisk ${FDISK_FLAGS}
	 currentsize=`${FDISK} $livedisk -installSize`

	 if [ -z "$reply" ]; then
		continue
         fi
         if [ -z "$currentsize" -o ${currentsize} -lt $MINSIZE ]; then
	       ${LOCALECHO} TOO_SMALL
	       reply=""
	       continue
	 else
	       break
	 fi
      else
	 reply=""
      fi
   done
fi	 

reply=""
while [ -z "$reply" ]
do
   clear
   ${LOCALECHO} READY
   echo
   echo -n "---> "
   read reply
   
   case $reply in
      1) continue;;
      2) echo
	 ${LOCALECHO} QUITTING
	 ${HALT} -e
	 exit 1;;
      *) reply="";;
   esac
done

# Get off the disk before we initialize it!
clear
${LOCALECHO} GOING
cd ${CDDIR}

ROOTDEV=`${FINDROOT}`

if [ $? -ne 0 ]; then
      ROOTTYPE=nfs
else
      ROOTTYPE=4.3
fi

${DISK} -i $livedisk >> /dev/null
    
if [ $? -ne 0 ]; then
    echo
    ${LOCALECHO} INITFAILED
    echo
    ${LOCALECHO} QUITTING
    echo
    ${SYNC} ; ${REBOOT}
    exit 1
fi

${MOUNT} -n /dev/$diskie ${HD} >> /dev/null

${MKDIRS} ${HD}/private/vm
${MKDIRS} ${HD}/private/tmp

${MKFILE} 16m ${HD}/private/vm/swapfile
${SWAPON} -o nocompress ${HD}/private/vm/swapfile

${DITTO} -T -arch ${ARCH} -bom /usr/lib/NextStep/BaseSystem.bom -outBom ${HD}/BaseSystem.bom / ${HD}
${MV} ${HD}/BaseSystem.bom ${HD}/usr/lib/NextStep/BaseSystem.bom

RECEIPT_DIR=/NextLibrary/Receipts

if [ "${LANGUAGE}" != "English" ]; then
    ${DITTO} -T -arch ${ARCH} -bom ${RECEIPT_DIR}/${LANGUAGE}Essentials.pkg/${LANGUAGE}Essentials.bom -outBom ${HD}/${LANGUAGE}Essentials.bom / ${HD}
    ${MKDIRS} ${HD}${RECEIPT_DIR}/${LANGUAGE}Essentials.pkg
    ${DITTO} ${RECEIPT_DIR}/${LANGUAGE}Essentials.pkg ${HD}${RECEIPT_DIR}/${LANGUAGE}Essentials.pkg
    ${MV} ${HD}/${LANGUAGE}Essentials.bom ${HD}${RECEIPT_DIR}/${LANGUAGE}Essentials.pkg/${LANGUAGE}Essentials.bom
fi

echo

echo "/dev/${diskie} / 4.3 rw,noquota,noauto 0 1" > ${HD}/private/etc/fstab

# Set permissions on / and /private/tmp
${CHMOD} 1777 ${HD}
${CHMOD} 1777 ${HD}/private/tmp

if [ "${ROOTTYPE}" = "4.3" ]; then
echo "${ROOTDEV} /NEXTSTEP_INSTALL 4.3 ro,noquota 0 2" \
   >> ${HD}/private/etc/fstab
fi

CUSTOM_FILE=/private/adm/CDIS.custom
echo "LANGUAGE=${LANGUAGE}" > ${HD}${CUSTOM_FILE}

if [ "${ARCH}" != "m68k" ]; then

   # Set up /private/Devices symlink
   ${LN} -s Drivers/${ARCH} ${HD}/private/Devices

   DEFAULT_FILE=/usr/Devices/System.config/Default.table

   # Write out CDIS.custom file
   ${MKDIRS} ${HD}/usr/Devices/System.config
   echo "ROOT=${ROOT}" >> ${HD}${CUSTOM_FILE}
   if [ "${ARCH}" = "i386" ]; then
      echo "FDISK_FLAGS=${FDISK_FLAGS}" >> ${HD}${CUSTOM_FILE}
   fi
   echo "diskie=${diskie}" >> ${HD}${CUSTOM_FILE}

   BOOTDRIVERS=`${SYSCONFIG} -c -a ${ARCH}`
   ${CP} ${ROOT}/private/Drivers/${ARCH}/System.config/Default.table ${HD}/usr/Devices/System.config/Default.install
   ${GREP} -v 'Boot Drivers' ${HD}/usr/Devices/System.config/Default.install > ${HD}${DEFAULT_FILE}
   echo "\"Boot Drivers\" = \"${BOOTDRIVERS}\";" >> ${HD}${DEFAULT_FILE}
   echo "\"Language\" = \"${LANGUAGE}\";" >> ${HD}${DEFAULT_FILE}
   
   INSTALLHINTS=${HD}/usr/Devices/System.config/InstallHints
   /bin/rm -rf ${INSTALLHINTS}
   /bin/mkdir ${INSTALLHINTS}
   for driver in ${BOOTDRIVERS}
   do
     ${SYSCONFIG} -d ${driver} > ${INSTALLHINTS}/${driver}.table 2>>/dev/null
   done
   ${CHMOD} -R 777 ${INSTALLHINTS}

# This routine will automatically install drivers located in 
# directory named /RELEASED_DRIVERS (placed into the install image)
# to the hard disk of the machine being installed.
# Added by Scott Vail 1995

  if [ "${ARCH}" = "i386" ]; then
    if [ -d /RELEASED_DRIVERS ]; then
	oldir=`/bin/pwd`
	packages=`/bin/ls /RELEASED_DRIVERS/*.pkg/*.tar.Z`
	cd ${HD}
	echo
	echo "Installing Device Drivers"
	for name in $packages
	do
	    bom=`echo $name|sed 's/tar\.Z/bom/'`
	    ${ZCAT} $name | ${ITAR} -xpfT - $bom
	done
	if [ -d ${HD}/private/Drivers/i386/ISASerialPort.config -a \
	     -d ${HD}/private/Drivers/i386/SerialPointingDevice.config ] ; then
	    ${CAT} ${HD}/private/Drivers/i386/System.config/Default.table | \
		${SED} 's/SerialMouse/SerialPointingDevice/' | \
		${SED} 's/SerialPorts/ISASerialPort/' > \
		${HD}/tmp/Default.table

	    ${MV} ${HD}/tmp/Default.table ${HD}/private/Drivers/i386/System.config
	fi
	cd $oldir
    fi
  fi

# -------------------
   # fixup Default.table if we did not boot from it.
   for i in ${BOOTDRIVERS}
   do
        # does the table exist?
        (${SYSCONFIG} -d $i | ${GREP} '"Default Table"')  >> /dev/null 2>&1
	STATUS=$?
	
	if [ ${STATUS} -eq 0 ]; then
	    # now grok it to get the driver name out
	    DEFAULTTABLE=`${SYSCONFIG} -d $i 2>>/dev/null | \
	        ${GREP} '"Default Table"' | \
		${AWK} -F= '{print $2}' | ${SED} 's/"//g' | \
		${SED} 's/;//g' | ${SED} 's/ //g'`
	    if [ "${DEFAULTTABLE}" != "Default" ];
            then
                DEST=${HD}/usr/Devices/${i}.config
                if [ -d ${DEST} ]; then
		    cd ${DEST}
		    ${MV} Default.table Install.table
		    ${MV} ${DEFAULTTABLE}.table Default.table
    
		    for lang in *.lproj
		    do
			${MV} ${lang}/Localizable.strings ${lang}/Install.strings
			${MV} ${lang}/${DEFAULTTABLE}.strings ${lang}/Localizable.strings
		    done
		fi
            fi
	fi
   done

# -------------------

fi

${SYNC}

echo
${CHECKFLOP} && ${DISK} -e /dev/rfd0a
${LOCALECHO} DONE
if [ "${ARCH}" = "i386" ]; then
    ${LOCALECHO} -q REMOVE_FLOPPY
else
    ${LOCALECHO} -q RESTART
fi
read glop
   ${LOCALECHO} RESTARTING
   ${REBOOT} 'sd -'
    exit 1
) < /dev/console >> /dev/console 2>&1
exit 0


OpenStep | Alliances | Training | Tech Support | Where to Buy