home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/bin/csh -f # # Create boot and drivers disks for a NetInstall client # Copyright (C) 1994 by NeXT Computer, Inc. All rights reserved. # All command names are stored in variables set AWK=/bin/awk set BASENAME=/usr/bin/basename set CAT=/bin/cat set CP=/bin/cp set DF=/bin/df set DISK=/usr/etc/disk set DU=/bin/du set ECHO=/bin/echo set ERROR=$ECHO set GREP=/bin/grep set HEAD=/usr/ucb/head set LIPO=/bin/lipo set LN=/bin/ln set LS=/bin/ls set MKDIRS=/bin/mkdirs set MOUNT=/usr/etc/mount set NIUTIL=/usr/bin/niutil set PS=/bin/ps set RM=/bin/rm set SED=/bin/sed set TAIL=/usr/ucb/tail set UMOUNT=/usr/etc/umount set ARCH_CMD=/usr/bin/arch set NEWFS=/etc/newfs set TRUE=1 set FALSE=0 set PROGRAM_NAME=`$BASENAME ${0} .csh` $ECHO -n "usage: ${PROGRAM_NAME} " > /tmp/_usage_$$ $ECHO '[-n] [-c network disk] [-d] [-NeXT_OD] [-config_domain name]' >> /tmp/_usage_$$ $ECHO 'options:' >> /tmp/_usage_$$ $ECHO " -n Don't initialize floppy disk" >> /tmp/_usage_$$ $ECHO ' -c network disk Custom disk for given network and disk drivers' >> /tmp/_usage_$$ $ECHO ' -d Create a drivers disk rather than a boot disk' >> /tmp/_usage_$$ $ECHO ' -NeXT_OD Create a boot optical disk for a NeXT computer' >> /tmp/_usage_$$ $ECHO ' -config_domain Domain where servers are recorded (default is "/")' >> /tmp/_usage_$$ # This program must be run by root set WHO=`$PS -l $$ | $TAIL -1 | $AWK '{print $2}'` if (${WHO}x != "0x") then $ERROR 'You must run this program as "root".' exit 1 endif # Determine host architecture #set ARCH=-UNKNOWN- set ARCH=`$ARCH_CMD` #$CAT /usr/lib/NextStep/software_version | $GREP Lightning > /dev/null #if ($status == 0) then if ($ARCH == m68k) then set ARCH=NeXT set M68K=$TRUE else #$CAT /usr/lib/NextStep/software_version | $GREP Thunder > /dev/null #if ($status == 0) then if ($ARCH == i386) then set M68K=$FALSE else #$CAT /usr/lib/NextStep/software_version | $GREP Blaze > /dev/null #if ($status == 0) then if ($ARCH == hppa) then set ARCH=hp endif endif endif if ($ARCH != NeXT && $ARCH != i386) then $ERROR 'You must run this program on a NeXT or Intel-based computer.' exit 1 endif # Parse command-line options set CONFIG_DOMAIN=/ set INIT_DISK=$TRUE set CUSTOM=$FALSE set DRIVERS_DISK=$FALSE set BLOCK_DEV=/dev/fd0a set RAW_DEV=/dev/rfd0a while ($#argv > 0) switch (${1}) case "-help": # Print help message $CAT /tmp/_usage_$$ $RM /tmp/_usage_$$ exit 1 breaksw case "-n": # Don't initialize disk set INIT_DISK=$FALSE breaksw case "-d": # Create a drivers disk set DRIVERS_DISK=$TRUE breaksw case "-c": # Custom disk if ($#argv < 3) then $ERROR "${PROGRAM_NAME}: missing arguments to -d" $CAT /tmp/_usage_$$ $RM /tmp/_usage_$$ exit 1 endif set CUSTOM=$TRUE set NETWORK_DRIVER="${2}" set DISK_DRIVER="${3}" shift shift breaksw case "-NeXT_OD": # Create a NeXT Optical Disk if ($ARCH != NeXT) then $ERROR '-NeXT_OD option only supported on a NeXT computer.' exit 1 endif set BLOCK_DEV=/dev/od0a set RAW_DEV=/dev/rod0a breaksw case "-config_domain": # Where servers are recorded if ($#argv < 2) then $ERROR "${PROGRAM_NAME}: missing argument to -config_domain." $CAT /tmp/_usage_$$ $RM /tmp/_usage_$$ exit 1 endif set CONFIG_DOMAIN="${2}" shift breaksw default: # Unknown flag $ERROR "${PROGRAM_NAME}: unknown option ${1}." $CAT /tmp/_usage_$$ $RM /tmp/_usage_$$ exit 1 breaksw endsw shift end $RM /tmp/_usage_$$ # Is there a NetInstall server? $NIUTIL -list $CONFIG_DOMAIN /locations/install_servers >& /dev/null if ($status == 1) then $ERROR 'Can't find any NetInstall servers.' exit 1 endif set SERVER_NAME=`$NIUTIL -list $CONFIG_DOMAIN /locations/install_servers | $HEAD -1 | $AWK '{print $2}'` set SERVER_IMAGE=`$NIUTIL -read $CONFIG_DOMAIN /locations/install_servers/$SERVER_NAME | $GREP install_root | $AWK '{print $2}'` set IMAGE_DIR=/Net/${SERVER_NAME}$SERVER_IMAGE $LS $IMAGE_DIR | $GREP "not found" if ($status == 0) then $ERROR 'Can't find NetInstall server $SERVER_NAME directory $IMAGE_DIR.' exit 1 endif # Make a NeXT disk? if ($M68K == $TRUE) then set CUSTOM=$FALSE set DRIVERS_DISK=$FALSE # Must be NeXT if ($ARCH != NeXT) then $ERROR 'You must run this program on an NeXT computer.' exit 1 endif else # Must be Intel if ($ARCH != i386) then $ERROR 'You must run this program on an Intel-based computer.' exit 1 endif endif # Is there a disk mounted? $GREP $BLOCK_DEV /etc/mtab > /dev/null if ($status == 0) then # There's a mounted disk in the drive. Abort. set DISK_NAME=`$GREP $BLOCK_DEV /etc/mtab | $AWK '{print $2}'` $ERROR "${PROGRAM_NAME}: Disk $DISK_NAME is present in the drive." $ERROR "${PROGRAM_NAME}: Unmount and eject the disk before running this command." exit 1 else if ($M68K == $FALSE) then # No disk present, get user to insert one $ECHO 'Please insert a floppy disk.' $ECHO -n 'Press Enter to proceed or type "quit" to exit: ' set USER_INPUT=$< if (${USER_INPUT}x == "quitx") then exit 0 endif endif endif # Initialize the disk if ($INIT_DISK == $TRUE && $DRIVERS_DISK == $FALSE) then $DISK -i -l NetInstall $RAW_DEV $NEWFS -i 8192 $RAW_DEV endif if ($INIT_DISK == $TRUE && $DRIVERS_DISK == $TRUE) then $DISK -i -l Drivers $RAW_DEV endif # Mount the disk set DISK_NAME=/tmp/_netinstall_$$ $MKDIRS $DISK_NAME $MOUNT $BLOCK_DEV $DISK_NAME $GREP "$DISK_NAME" /etc/mtab > /dev/null if ($status == 1) then $ERROR "${PROGRAM_NAME}: Disk error." exit 1 endif # Create drivers disk if -d flag specified if ($DRIVERS_DISK == $TRUE) then # create /private/Drivers/i386 $MKDIRS $DISK_NAME/private/Drivers/i386 # Get a list of boot drivers set NET_TABLE=$IMAGE_DIR/private/Drivers/i386/System.config/Instance0.network set BOOT_DRIVERS=`$GREP "Boot Drivers" $NET_TABLE | $SED 's/"Boot Drivers" = "//' | $SED 's/";//'` # if a custom disk, copy specified network and disk drivers if ($CUSTOM == $TRUE) then set ALL_DRIVERS=`$ECHO $BOOT_DRIVERS $NETWORK_DRIVER $DISK_DRIVER` else set ALL_DRIVERS=`$ECHO $BOOT_DRIVERS` # Find available network and disk drivers foreach DRIVER ($IMAGE_DIR/private/Drivers/i386/*.config) set DRIVER_NAME=`$BASENAME $DRIVER .config` set FAMILY=`$GREP '"Family"' $DRIVER/Default.table | $AWK '{print $3}' | $SED 's/"//g' | $SED 's/;//'` if ($FAMILY == "Network" || $FAMILY == "Disk" || $FAMILY == "SCSI") then if ($DRIVER_NAME != "Floppy" \ && $DRIVER_NAME != "IBMTokenRing" \ && $DRIVER_NAME != "TokenExpress") then set ALL_DRIVERS=`$ECHO $ALL_DRIVERS $DRIVER_NAME` endif endif end endif # Copy Drivers foreach DRIVER ($ALL_DRIVERS) set DRIVER_SRC=$IMAGE_DIR/private/Drivers/i386/$DRIVER.config set DRIVER_DST=$DISK_NAME/private/Drivers/i386/$DRIVER.config if (! -d $DRIVER_SRC) then $ERROR "${PROGRAM_NAME}: Can't find $DRIVER_SRC" else $MKDIRS $DRIVER_DST $CP $DRIVER_SRC/*_reloc $DRIVER_DST $CP $DRIVER_SRC/*.table $DRIVER_DST $RM -f $DRIVER_DST/Instance*.table foreach LANG ($DRIVER_SRC/*.lproj) $MKDIRS $DRIVER_DST/`$BASENAME $LANG` $CP $LANG/*.strings $DRIVER_DST/`$BASENAME $LANG` end endif end # Unmount and eject the disk $UMOUNT $BLOCK_DEV $DISK -e $RAW_DEV $RM -f $DISK_NAME # All done (drivers disk) $ECHO "NetInstall boot disk build complete." $ECHO "You may remove the disk." exit 0 endif # Make a NeXT boot disk if ($M68K == $TRUE) then $DISK -B $IMAGE_DIR/usr/standalone/boot $RAW_DEV $LIPO $IMAGE_DIR/mach_kernel -extract m68k -output ${DISK_NAME}/sdmach $LN $DISK_NAME/sdmach $DISK_NAME/fdmach $LN $DISK_NAME/sdmach $DISK_NAME/odmach # Unmount and eject the disk $UMOUNT $BLOCK_DEV $DISK -e $RAW_DEV $RM -f $DISK_NAME # All done $ECHO "NetInstall boot disk build complete." exit 0 endif # Make an Intel boot disk $DISK -B $IMAGE_DIR/usr/standalone/i386/boot $RAW_DEV $LIPO $IMAGE_DIR/mach_kernel -extract i386 -output ${DISK_NAME}/mach_kernel # Create /usr/standalone/i386/English.lproj $MKDIRS $DISK_NAME/usr/standalone/i386/English.lproj # Copy sarld $CP $IMAGE_DIR/usr/standalone/i386/sarld $DISK_NAME/usr/standalone/i386 # Copy /usr/standalone/i386/Language.table $CP $IMAGE_DIR/usr/standalone/i386/Language.table $DISK_NAME/usr/standalone/i386 # Copy /usr/standalone/i386/BootHelp.txt $CP $IMAGE_DIR/usr/standalone/i386/BootHelp.txt $DISK_NAME/usr/standalone/i386 # Create /usr/standalone/i386/English.lproj/Localizable.strings $CAT << END_OF_STRINGS > /tmp/_strings_$$ "Loading NEXTSTEP"; "Loading %s\n"; "Reading NEXTSTEP configuration"; "Couldn't load standalone linker; unable to load boot drivers.\n"; "Insert file system media and press Return"; "Errors encountered while starting up the computer.\n"; "Pausing 5 seconds...\n"; "Starting NEXTSTEP"; "Can't find %s\n"; "Couldn't start up the computer using this floppy disk."; "Error loading %s\n"; "Fat binary file doesn't contain i386 code\n"; "Unrecognized binary format\n"; "Error reading commands\n"; "Error loading section\n"; "Read error\n"; "Can't load driver %s without sarld\n"; "Driver %s is larger than %d bytes and can't be loaded.\n"; "Error occurred while linking driver %s:\n%s"; "The floppy disk in the drive contains the following SCSI adapter and hard disk controller device drivers:\n"; "Loading driver %s\n"; "Error loading driver %s\n"; "The driver was not loaded. "; "The driver was loaded successfully. "; "Press Return to continue.\n"; "Type 1 to load a device driver from the disk in the floppy disk drive.\n"; "Type 2 to continue without loading additional device drivers.\n"; "When you began installing NEXTSTEP, you loaded the following device drivers from a floppy disk:\n"; "Insert the floppy disk that contains these device drivers.\n"; "If you have a floppy disk with NEXTSTEP device drivers that you need to use during installation, insert the floppy disk that contains the device driver for that device.\n"; "The following SCSI adapter and hard disk controller device drivers are available while installing NEXTSTEP:\n"; "If you have a different kind of SCSI adapter or hard disk controller, insert the floppy disk that contains its device driver.\n"; "Searching for drivers"; "Couldn't find /private/Drivers/i386\n"; "There are no device drivers on this floppy disk.\n"; "Error in standalone linker executable\n"; "No room in memory for config file %s\n"; "Reading config: %s\n"; "Config file \"%s\" not found\n"; "System config file '%s' not found\n"; "Loading binary for %s\n"; "Warning: No active drivers specified in system config\n"; "Type the number for the device driver you want to install.\n"; "Type %d to view a list of additional device drivers on this disk.\n"; "Type %d to continue without installing a device driver from this disk.\n"; "The floppy disk in the drive contains device drivers for the following SCSI adapters and hard disk controllers:\n" = "The floppy disk in the drive contains device drivers for the following SCSI adapters, hard disk controllers, and network adapters:\n"; "MESSAGE1" = "Type the number for the network adapter in your computer.\n\n"; "MESSAGE2" = "Type the number for the SCSI adapter or hard disk controller that the hard disk you want to install NEXTSTEP on is connected to.\n\n"; "MESSAGE3" = "If you have another disk with the device driver for this network adapter, insert that disk in the floppy disk drive and type %d.\n"; "MESSAGE4" = "If you have another disk with the device driver for this SCSI adapter or hard disk controller, insert that disk in the floppy disk drive and type %d.\n"; END_OF_STRINGS $CP /tmp/_strings_$$ $DISK_NAME/usr/standalone/i386/English.lproj/Localizable.strings $RM /tmp/_strings_$$ # Copy /private/Drivers/i386/System.config/Instance0.network to Instance0.table $MKDIRS $DISK_NAME/private/Drivers/i386/System.config # if a custom disk, include specified network and disk drivers in Boot Drivers set NET_TABLE=$IMAGE_DIR/private/Drivers/i386/System.config/Instance0.network if ($CUSTOM == $TRUE) then set BOOT_DRIVERS=`$GREP "Boot Drivers" $NET_TABLE | $SED 's/"Boot Drivers" = "//' | $SED 's/";//'` set BOOT_DRIVERS=`$ECHO $BOOT_DRIVERS $NETWORK_DRIVER $DISK_DRIVER` $ECHO -n '"Boot Drivers" = "' > /tmp/_table_$$ $ECHO -n $BOOT_DRIVERS >> /tmp/_table_$$ $ECHO '";' >> /tmp/_table_$$ $ECHO '"Install Mode" = "No";' >> /tmp/_table_$$ $GREP -v "Boot Drivers" $NET_TABLE | $GREP -v "Install Mode" >> /tmp/_table_$$ $CP /tmp/_table_$$ $DISK_NAME/private/Drivers/i386/System.config/Instance0.table $RM /tmp/_table_$$ else $CP $NET_TABLE $DISK_NAME/private/Drivers/i386/System.config/Instance0.table endif # Unmount and eject the floppy disk $UMOUNT $BLOCK_DEV $DISK -e $RAW_DEV $RM -f $DISK_NAME # All done $ECHO "NetInstall boot disk build complete." $ECHO "You may remove the disk." exit 0