# @(#)common	30.1 3/13/91 AppEng/SCCS Interphase
# Interphase Corporation Northern CA. Standards for Coding based on
# DOD-STD-2167A ( Draft )
#
# ABSTRACT :  common code for Interphase driver installation scripts
#       C shell script that installs Interphase device driver support
#       for Sun OS3.4, OS3.5 , OS3.2, OS4.0, OS4.0.1, OS4.0.3, & OS4.1

# KEYWORDS : common
#

# CONTENTS
#
#                  Ident        Date            Author
# -------------------------------------------------------------------------
# Designed By :    X01.00       17-Sep-90       Robert Hogue
#
# Coded By    : Robert Hogue (rogue)
# Tested By   : rogue (Sun3 OS3.5 and 4.0 and Sun4 OS4.0 only)
#               modifications for Sun OS3.2 done without testing locally

# Revision History :
#
# Rev#  Date     Author   Change
#--------------------------------------------------------------------------
# 30.1  03-13-91 rbrant   New development/distribution format.
#  1.00 09-17-90 rogue    creation date

# Examples of Usage : common is 'source'd by installation shell scripts
#

# Parameter Description :
#    NAME  is set by the calling script and should be the name of the
#          directory containing the calling script.  Ex : 3207_install
#          should be in a directory called '3207' ( NAME = '3207' ).
#          Do not change the directory name!

# Special Design Considerations : requires 'plain vanilla' system with local
#       disk drive.  Local disk must have 'kernel build' files in the
#       appropriate Sun directories.

# External Units Accessed :  ( Called, Imported, Copied, WITHed, referenced )
#
#   System Files modified :
#
#       $SYSDIR/sun/conf.c (block and character devices only)
#       $CONF/devices (devices.sunX)
#       $CONF/files (files.sunX)
#       /etc/fstab (emulation mode installation only)
#       $SYSDIR/sundev/ip_conf ('ip' installation on 4.0.3 only)
#
#
#     Unit Name                        Purpose
#-------------------------------------------------------------------------
#
#  awkfiles/             all units this directory (awk files for "fix..")
#  closingnotes.$NAME    text file is output upon completion of XXXX_install
#  config.appendum.$NAME text file appended to the configuration file
#  cycle                 log file
#  drivers/              all units this directory (device driver sources)
#  fix/                  all units this directory (input files for "fix..")
#  warning               log file
 
# Exceptions and the Conditions which will raise them :
#     exceptions (warnings) are logged to the 'warning' file
#
#     non-existent system directories cause fatal errors and immediate exit
#     failed compilations cause exceptions
#
 
# Input / Output : ( Files, Keyboards, Consoles, printers, modems, etc. )
#
#     Device name    Access type      Purpose      Summary
#------------------------------------------------------------------------
#
 
# Machine Dependencies : ( registers, storage, ports, machine code, etc. )
#
# Access type      Purpose                        Justification
#-----------------------------------------------------------------------
 
# Program Notes :
#
 
# Assumptions :
#
 
# Deficiencies :
#

set noglob
set nonomatch
set prompt = '=====> '
set true   = 1
set false  = 0
set date   = `date`

setenv OS3_2FLAG   false	# flag set if the system is 3.2, else clear
setenv OS4_0_1FLAG false	# flag set if system is 4.0.1,  else clear
setenv OS4_0_3FLAG false	# flag set if system is 4.0.3,  else clear
setenv OS4_1FLAG   false	# flag set if system is 4.1,  else clear

setenv FATAL_ERROR  false	# flag set if fatal error in common, else clear
setenv ABORT_SCRIPT false	# flag set if abort, else clear

set DIAGOUTPUT = '/dev/null'	# the diagnostic output file
#set DIAGOUTPUT = 'test'	# the diagnostic output file

setenv OURCONFIGFILE config.appendum.$NAME  #append this file to config file

set SCONFIGFILE = GENERIC	# default input configuration file
set DO_CLIENTS  = false		# flag set for os4 client support, else clear
set EXCEPTIONS  = false		# flag set if certain errors,  else clear

set RELEASE3 = /usr/sys/conf/RELEASE    # the path and file containing the OS3.5
                                        # version number
set RELEASE4 = /usr/share/sys/conf.common/RELEASE  # the path and file
                                        # containing the OS4 version number
 
#*****************************************************************************#
# Create the Diagnostic log file
#*****************************************************************************#
echo "" > $DIAGOUTPUT
echo "Diagnostic output file for ${NAME}_install" >> $DIAGOUTPUT
echo "Date $date" >> $DIAGOUTPUT
echo "" >> $DIAGOUTPUT

#*****************************************************************************#
# Get the System type
#*****************************************************************************#
clear
	echo ""
	echo "              Interphase $NAME Driver Installation Script"
	echo "                       for SUN(tm) Computers"
	echo "                            $version"
	echo ""

set ans = `arch`		#command returns system type
echo "arch = $ans" >> $DIAGOUTPUT
goto checktype

system_type:			# take this path if 'arch' command fails
	echo ""			# to return a known system type
	echo "Is this a sun2, sun3, or sun4 ? "
	echo ""
        echo -n "$prompt (sun2 sun3 sun4) : "
	set ans = $<

checktype:			# check the system type
	switch ( $ans )
		case "sun2"
			echo ""
			echo "Installation for Sun 2 CPU"
			set SYSTYPE = sun2
			breaksw
		case "sun3"
			echo ""
			echo "Installation for Sun 3 CPU"
			set SYSTYPE = sun3
			breaksw
		case "sun4"
			echo ""
			echo "Installation for Sun 4 CPU"
			set SYSTYPE = sun4
			breaksw
		default:
			echo " Sorry but this script does not support $ans. "
			echo " Hit 'q' to abort, anything else to continue "
			set bans = $<
			if ( $bans == q ) then 
			    goto exitinterrupt
			endif
			goto system_type
         		breaksw
	endsw
echo "SYSTYPE = $SYSTYPE" >> $DIAGOUTPUT

#*****************************************************************************#
# Installation for the appropriate sun operating system                       #
#*****************************************************************************#
which_os:

unset bans			# clear temp variables
unset ans

if ( -e $RELEASE3 ) then	#if "Release" is where it should be for os3x..
    set i = `cat $RELEASE3`
else if ( -e $RELEASE4 ) then	# or ox4.x..
    set i = `cat $RELEASE4`
else				# "Release" not found in the default directory
    onintr os_type		# goto manual entry if the user interrupts
    echo ""
    echo "Standby, searching /usr/sys for the Operating System (os) release number."
    echo "Hit <CONTROL-C> to manually enter the os release number.."
    set RELEASE = `find /usr/sys -name RELEASE -print`

    if ( $#RELEASE == 0 ) then
        echo ""
        echo "Search for os release number failed"
        goto os_type
    else
        set j = $RELEASE[1] 	# allow for the really strange case of more than
				# one 'release' file.
        if ( $j =~ "" ) then
            echo ""
            echo "Search for os release number failed"
            goto os_type
        else
            set i = `cat $j`
        endif
    endif
endif

goto check_os_type

os_type:		# this path is taken if the search for a valid os
			# release number fails OR if the user <control-c>'d
			# out of the "find" command that searches for the
			# release number.
onintr			# allow untrapped interrupts
echo ""
echo "Installation for which Sun operating system ?"
echo ""
echo "          Choices :  3.2 (Sun4 only)"
echo "                     3.4 (Sun3 only)"
echo "                     3.5 (Sun3 only)"
echo "                     4.0 "
echo "                     4.0.1"
echo "                     4.0.3"
echo "                     4.1"
echo "                     4.1.1"
echo ""
echo -n "$prompt (3.2  3.4  3.5  4.0  4.0.1  4.0.3  4.1  4.1.1) : "
set i = $<

check_os_type:		# check for a valid os release number

# the following commands added for the Sun export market
# this is the shell's attempt to determine the OS type automatically
# takes 3.5_Export, 3.5EXPORT, etc and converts to an array where the
# first element is the OS release number.  Simple and quick.
if ( $i !~ "" ) then
    set j = `echo $i | sed -e 's/_/ /g' -e 's/E/ /g' -e 's/e/ /g'`
    set i = $j[1]
else
    echo ""
    echo "The OS release number is blank"
    goto os_type
endif

# now test for valid OS release numbers
switch ( $i )
    case ""
        goto os_type 
    breaksw

    case "3.2"
        if ( $SYSTYPE == sun3 ) then
            echo ""
            echo "3.2 not valid for Sun3"
            goto os_type
        else
            echo ""
            echo "Install Interphase drivers for Sun os3.2" 
            setenv OS3_2FLAG true
            set OS = "os3"
        endif
    breaksw

    case "3.4"
        if ( $SYSTYPE == sun4 ) then
            echo ""
            echo "3.4 not valid for Sun4"
            goto os_type
        else
            echo ""
            echo "Install Interphase drivers for Sun os3.4" 
            set OS = "os3"
        endif
    breaksw

    case "3.5"
        if ( $SYSTYPE == sun4 ) then
            echo ""
            echo "3.5 not valid for Sun4"
            goto os_type
        else
            echo ""
            echo "Install Interphase drivers for Sun os3.5" 
            set OS = "os3"
        endif
    breaksw

    case "4.0" 
        echo ""
        echo "Install Interphase drivers for Sun os4.0" 
        set OS = "os4"
    breaksw

    case "4.0.1" 
        echo ""
        echo "Install Interphase drivers for Sun os4.0.1" 
        set OS = "os4"
        setenv OS4_0_1FLAG true
    breaksw

    case "4.0.3" 
        echo ""
        echo "Install Interphase drivers for Sun os4.0.3" 
        set OS = "os4"
        setenv OS4_0_3FLAG true
    breaksw

    case "4.1"
        echo ""
        echo "Install Interphase drivers for Sun os4.1"
        set OS = "os4"
        setenv OS4_1FLAG true
    breaksw

    case "4.1.1"
        echo ""
        echo "Install Interphase drivers for Sun os4.1.1"
        set OS = "os4"
        setenv OS4_1FLAG true
    breaksw

    # This case is taken if the system does find a system release # for os3.2
    case "Sys4-3.2_REV2"
        if ( $SYSTYPE == sun3 ) then
            echo ""
            echo "3.2 not valid for Sun3"
            goto os_type
        else
            echo ""
            echo "Install Interphase drivers for Sun os3.2" 
            setenv OS3_2FLAG true
            set OS = "os3"
        endif
    breaksw

    default:
        echo ""
        echo "Sorry but this script does not support Sun os$i"
        goto os_type
    breaksw
endsw

echo "OS = $OS" >> $DIAGOUTPUT

#*****************************************************************************#
# Initialize the script variables
#*****************************************************************************#
if ( $OS =~ "os3" ) then
    set SYSDIR = /usr/sys		# path to the system build files
    set OURDIR = `pwd`			# path to the interphase directory
    set CONF   = /usr/sys/conf		# path to conf directory
    set UNIX   = /usr/sys		# path to configuration directories
    setenv OS os3

else if ( $OS =~ "os4" ) then
    set SYSDIR = /usr/share/sys			# path to system build files
    set OURDIR = `pwd`				# path to interphase files
    set CONF   = /usr/share/sys/$SYSTYPE/conf	# path to config directory
    set UNIX   = /usr/share/sys/$SYSTYPE	# path to kernel build directory
    # client modifications supported on OS4 only
    set CLIENTSUN2 = /usr/share/sys/sun2/conf	# path to sun2 client directory
    set CLIENTSUN3 = /usr/share/sys/sun3/conf	# path to sun3 client directory
    set CLIENTSUN4 = /usr/share/sys/sun4/conf	# path to sun4 client directory
    setenv OS os4

    # check for the Sun3/400 as the 'arch' command returns the incorrect value
    # on this machine
    set MACHINE = `mach`

    if ( $SYSTYPE == "sun3" && $MACHINE == "mc68030" ) then
	echo ""
	echo -n "Machine type is a Sun3/400"
	set CONF   = /usr/share/sys/sun3x/conf    # path to config directory
	set UNIX   = /usr/share/sys/sun3x   # path to kernel build directory
    endif
else
    echo ""
    echo "Illegal OS type ( $OS )"
    goto os_type
endif

#*****************************************************************************#
# Where are the necessary files located ?                                     #
#*****************************************************************************#
echo ""
echo "What is the path to the System Directory ?"
echo "		Default : $SYSDIR"
echo ""
echo -n $prompt
set ans = $<
if ( $ans !~ "" ) then
	set SYSDIR = $ans
endif

echo ""
echo "What is the path to the Interphase Directory ?"
echo "		Default : $OURDIR"
echo ""
echo -n $prompt
set ans = $<
if ( $ans !~ "" ) then
	set OURDIR = $ans
endif

echo ""
echo "What is the path to the Configuration Directory ?"
echo "		Default : $CONF"
echo ""
echo -n $prompt
set ans = $<
if ( $ans !~ "" ) then
	set CONF = $ans
endif

echo ""
echo "Note : The input configuration file is not modified in any way"
echo "Configuration file to use as a starting point (the input file) ?"
echo "		Default : $SCONFIGFILE"
echo ""
echo -n $prompt
set ans = $<
if ( $ans !~ "" ) then
	set SCONFIGFILE = $ans
endif

echo ""
echo "New configuration file name (the output file) ?"
echo "		Default : $NEWCONFIGFILE"
echo ""
echo -n $prompt
set ans = $<
if ( $ans !~ "" ) then
	setenv NEWCONFIGFILE $ans
endif

#*****************************************************************************#
# Create the 'warning' log file                                               #
#*****************************************************************************#
echo "" > $OURDIR/warning
echo "The following exceptions or warnings were generated :" >> $OURDIR/warning
echo "" >> $OURDIR/warning

#*****************************************************************************#
# Are the filesystems big enought for this script?                            #
#*****************************************************************************#
echo ""
echo "Checking filesystem sizes"

set ans = `/bin/df / | /bin/grep /dev`
@ b = $ans[4]

echo "ROOT SIZE = $b" >> $DIAGOUTPUT

if ( $b < 2000 ) then
    echo "/ (root) is less than 2 MB" >> $OURDIR/warning
    echo "/ (root) is less than 2 MB"
else
    echo ""
    echo "/ (root) is greater than 2 MB"
endif

set ans = `/bin/df $SYSDIR | /bin/grep /dev`
@ b = $ans[4]

echo "SYSTEM SIZE = $b" >> $DIAGOUTPUT

if ( $b < 5000 ) then
    echo "System Directory filesystem is less than 5 MB"
    echo "System Directory filesystem is less than 5 MB" >> $OURDIR/warning
else
    echo ""
    echo "System Directory filesystem is greater than 5 MB"
endif

set ans = `/bin/df $OURDIR | /bin/grep /dev`
@ b = $ans[4]

echo "IPHASE SIZE = $b" >> $DIAGOUTPUT

if ( $b < 5000 ) then
    echo "Interphase filesystem is less than 5 MB" >> $OURDIR/warning
    echo "Interphase filesystem is less than 5 MB"
else
    echo ""
    echo "Interphase filesystem is greater than 5 MB"
endif

#*****************************************************************************#
# Reinitialize variables based on the pathname input                          #
#*****************************************************************************#

# Client modifications supported on os4.x only
if ( $OS =~ "os4" ) then
    set CLIENTSUN2 = $SYSDIR/sun2/conf
    set CLIENTSUN3 = $SYSDIR/sun3/conf
    set CLIENTSUN4 = $SYSDIR/sun4/conf
endif

# where are the supplemental interphase files located ?
setenv DRIVERS $OURDIR/drivers
setenv FIXFILES $OURDIR/fix
setenv AWKFILES $OURDIR/awkfiles

# where are the kernel build directories located ?
if ( $OS3_2FLAG == true || $OS =~ "os4" ) then		#if this is os3.2 or 4.0
    set UNIX   = $SYSDIR/$SYSTYPE
else
    set UNIX   = $SYSDIR
endif

#*****************************************************************************#
# Add support for client machines?                                            #
#*****************************************************************************#
#
if ( $OS =~ "os4" ) then		#if this is 4.0
    echo ""
    echo "Add Interphase support to 'files' and 'devices' for os4"
    echo "client machines ?"
    echo ""
    echo "This support is required if :"
    echo "   (1)  you have diskless nodes connected to this machine AND"
    echo "   (2)  nodes are of a different architechure, eg. Sun3 remote"
    echo "        booting from a Sun4, etc. AND"
    echo "   (3)  You ever want to compile a new kernel for the remote machines"
    echo ""
    echo -n "Add client support (y/n) : "
    set i = $<
    if ( $i =~ "no"|| $i =~ "No"|| $i =~ "NO"|| $i =~ "n"|| $i =~ "N" ) then
	echo ""
	echo "No Client support will be added"
    else
	set DO_CLIENTS = true
	echo ""
	echo "Client support will be added"
    endif
endif

echo "DO_CLIENTS = $DO_CLIENTS" >> $DIAGOUTPUT

#*****************************************************************************#
# Check for valid directories.  Failures at this point are fatal              #
#*****************************************************************************#
echo ""
echo "Checking for valid directories"

if !( -d $OURDIR ) then			# a valid interphase directory?
	echo ""
	echo "Not a valid directory : $OURDIR"
	echo "Not a valid directory : $OURDIR" >> $DIAGOUTPUT
	goto fatal_error_exit
endif

if !( -d $SYSDIR ) then			# a valid system directory?
	echo ""
	echo "Not a valid directory : $SYSDIR"
	echo "Not a valid directory : $SYSDIR" >> $DIAGOUTPUT
	goto fatal_error_exit
endif

if !( -d $SYSDIR/$USER_DRIVERS ) then	# a valid USER_DRIVERS directory?
	echo ""
	echo "Not a valid directory : $SYSDIR/$USER_DRIVERS"
	echo "Not a valid directory : $SYSDIR/$USER_DRIVERS" >> $DIAGOUTPUT
	goto fatal_error_exit
endif

if ! ( -d $CONF ) then			#valid conf directory?
	echo ""
	echo "Not a valid directory : $CONF"
	echo "Not a valid directory : $CONF" >> $DIAGOUTPUT
	goto fatal_error_exit
endif

if !( -d $SYSDIR/sun ) then             # a valid sun directory?
        echo ""
        echo "Not a valid directory : $SYSDIR/sun"
        echo "Not a valid directory : $SYSDIR/sun" >> $DIAGOUTPUT
        goto fatal_error_exit
endif

echo "Directory check done" >> $DIAGOUTPUT

#*****************************************************************************#
# Check for valid device driver files.  Failures are fatal
#*****************************************************************************#
echo ""
echo "Checking for valid device driver files"

foreach i ( $IPFILES )
    if ! ( -e $DRIVERS/$i ) then  #check for the existence of the driver file
       echo ""
       echo "File $DRIVERS/$i not found.. fatal error"
       echo "File $DRIVERS/$i not found.. fatal error" >> $DIAGOUTPUT
       goto fatal_error_exit
    endif
end

echo "Device driver check done" >> $DIAGOUTPUT

#*****************************************************************************#
# Check for valid system files.  Failures at this point are fatal             #
#*****************************************************************************#
echo ""
echo "Checking for valid files"

if ! ( -e $SYSDIR/sun/swapgeneric.c ) then
    echo ""
    echo "Not a valid file : $SYSDIR/sun/swapgeneric.c"
    echo "Not a valid file : $SYSDIR/sun/swapgeneric.c" >> $DIAGOUTPUT
    goto fatal_error_exit
endif

if ! ( -e $SYSDIR/sun/conf.c ) then
    echo ""
    echo "Not a valid file : $SYSDIR/sun/conf.c" >> $DIAGOUTPUT
    echo "Not a valid file : $SYSDIR/sun/conf.c"
    goto fatal_error_exit
endif

if ! ( -e /etc/fstab ) then
    echo ""
    echo "Not a valid file : /etc/fstab"
    echo "Not a valid file : /etc/fstab" >> $DIAGOUTPUT
    goto fatal_error_exit
endif

if ! ( -e $CONF/$SCONFIGFILE ) then
	echo ""
	echo "Not a valid file : $CONF/$SCONFIGFILE"
	echo "Not a valid file : $CONF/$SCONFIGFILE" >> $DIAGOUTPUT
	goto fatal_error_exit
endif

if ( $OS3_2FLAG == true || $OS =~ "os4" ) then		#if this is os3.2 or 4.0
    if ! ( -e $CONF/files ) then
        echo ""
        echo "Not a valid file : $CONF/files"
        echo "Not a valid file : $CONF/files" >> $DIAGOUTPUT
        goto fatal_error_exit
    endif

    if ! ( -e $CONF/devices ) then
        echo ""
        echo "Not a valid file : $CONF/devices"
        echo "Not a valid file : $CONF/devices" >> $DIAGOUTPUT
        goto fatal_error_exit
    endif
else					#do this if not os3.2 or os4
    if ! ( -e $CONF/files.$SYSTYPE ) then
	echo ""
	echo "Not a valid file : $CONF/files.$SYSTYPE"
	echo "Not a valid file : $CONF/files.$SYSTYPE" >> $DIAGOUTPUT
	goto fatal_error_exit
    endif

    if ! ( -e $CONF/devices.$SYSTYPE ) then
        echo ""
        echo "Not a valid file : $CONF/devices.$SYSTYPE"
        echo "Not a valid file : $CONF/devices.$SYSTYPE" >> $DIAGOUTPUT
        goto fatal_error_exit
    endif
endif		#if os3.2 or os4
echo "Valid file check done" >> $DIAGOUTPUT

#*****************************************************************************#
# Set the interrupt handler                                                   #
#*****************************************************************************#
onintr exitinterrupt

#*****************************************************************************#
#  Set up the 'cycle' file                                                    #
#      cycle keeps track of the number of times this script is run            #
#*****************************************************************************#

touch $OURDIR/cycle
set numm = `tail -1 $OURDIR/cycle`
if ( $#numm == 0 ) then
	set num = 0
else
	set num = $numm[1]
endif
@ num++
echo "$num cycle on $date " >> $OURDIR/cycle

#*****************************************************************************#
# Copy the driver files to sundev or sunif
#*****************************************************************************#
echo ""
echo "Copying Interphase driver files to $SYSDIR/$USER_DRIVERS"
echo "Copying Interphase driver files to $SYSDIR/$USER_DRIVERS" >> $DIAGOUTPUT
foreach i ( $IPFILES )
    if ! ( -e $SYSDIR/$USER_DRIVERS/$i ) then
 	/bin/cp $DRIVERS/$i $SYSDIR/$USER_DRIVERS/$i
    else
 	cmp -s $DRIVERS/$i $SYSDIR/$USER_DRIVERS/$i
        if ( $status ) then
	    echo "$USER_DRIVERS/$i ===> $USER_DRIVERS/$i.$num " >> $OURDIR/warning
	    echo "$DRIVERS/$i was copied over $USER_DRIVERS/$i " >> $OURDIR/warning
	    /bin/mv $SYSDIR/$USER_DRIVERS/$i $SYSDIR/$USER_DRIVERS/$i.$num
	    /bin/cp $DRIVERS/$i $SYSDIR/$USER_DRIVERS/$i
        endif
    endif
end
echo "Driver copy done" >> $DIAGOUTPUT

cd $OURDIR

#*****************************************************************************#
# Backup and modify the user's 'files' file
#*****************************************************************************#
echo "Fix files start" >> $DIAGOUTPUT

if ( $OS3_2FLAG == true || $OS =~ "os4" ) then
    if ! ( -e $CONF/files.before.IP ) then
        echo ""
        echo "Backing up $CONF/files as $CONF/files.before.IP"
       /bin/cp $CONF/files $CONF/files.before.IP
    endif
    echo ""
    echo "Updating $CONF/files"

    # add pathnames for the interphase files to the 'files' file
    #
    ed $CONF/files < $FIXFILES/fixsunfiles.in >>& $DIAGOUTPUT

    # make sure the mods to 'files' worked and set exception if not
    #
    cmp -s $CONF/files $CONF/files.before.IP
    if ! ( $status ) then
        echo ""
        echo "Update of the 'files' file failed" 
        echo "Update of the 'files' file failed" >> $OURDIR/warning
        echo "Update of the 'files' file failed" >> $DIAGOUTPUT
        set EXCEPTIONS = true
    endif
else			# else is taken if os3.5 only
    if ! ( -e $CONF/files.$SYSTYPE.before.IP ) then
        echo ""
        echo "Backing up $CONF/files.$SYSTYPE as $CONF/files.$SYSTYPE.before.IP" 
        /bin/cp $CONF/files.$SYSTYPE $CONF/files.$SYSTYPE.before.IP
    endif

    echo ""
    echo "Updating $CONF/files.$SYSTYPE "
     
    # add pathnames for the interphase files to the 'files.sunX' file
    #
    ed $CONF/files.$SYSTYPE < $FIXFILES/fixsunfiles.in >>& $DIAGOUTPUT
 
    # make sure the mods to 'files.sunX' worked and set exception if not
    #
    cmp -s $CONF/files.$SYSTYPE $CONF/files.$SYSTYPE.before.IP
    if ! ( $status ) then
        echo ""
        echo "Update of the 'files.$SYSTYPE' file failed"
        echo "Update of the 'files.$SYSTYPE' file failed" >> $OURDIR/warning
        echo "Update of the 'files.$SYSTYPE' file failed" >> $DIAGOUTPUT
        set EXCEPTIONS = true
    endif
endif	#os3.2

echo "Done with mods to 'files' file" >> $DIAGOUTPUT

#*****************************************************************************#
# Backup and modify the os4 user's client 'files' files                       #
#*****************************************************************************#
#  No error checking done during this routine

if ( $OS =~ "os4" && $DO_CLIENTS == true ) then
    if ( -d $CLIENTSUN4 && $SYSTYPE !~ "sun4" ) then
        if ! ( -e $CLIENTSUN4/files.before.IP ) then
            echo ""
            echo "Backing up and Updating $CLIENTSUN4/files"
            /bin/cp $CLIENTSUN4/files $CLIENTSUN4/files.before.IP
        endif
        ed $CLIENTSUN4/files < $FIXFILES/fixsunfiles.in >>& $DIAGOUTPUT
    endif   #CLIENTSUN4

    if ( -d $CLIENTSUN3 && $SYSTYPE !~ "sun3" ) then
        if ! ( -e $CLIENTSUN3/files.before.IP ) then
            echo ""
            echo "Backing up and Updating $CLIENTSUN3/files"
            /bin/cp $CLIENTSUN3/files $CLIENTSUN3/files.before.IP
        endif
        ed $CLIENTSUN3/files < $FIXFILES/fixsunfiles.in >>& $DIAGOUTPUT
    endif   #CLIENTSUN3

    if ( -d $CLIENTSUN2 && $SYSTYPE !~ "sun2" ) then
        if ! ( -e $CLIENTSUN2/files.before.IP ) then
            echo ""
            echo "Backing up and Updating $CLIENTSUN2/files"
            /bin/cp $CLIENTSUN2/files $CLIENTSUN2/files.before.IP
        endif
        ed $CLIENTSUN2/files < $FIXFILES/fixsunfiles.in >>& $DIAGOUTPUT
    endif   #CLIENTSUN2
endif	#os4.0

#*****************************************************************************#
# Create a new configuration file                                             #
#*****************************************************************************#

echo ""
echo "Creating the configuration file : $CONF/$NEWCONFIGFILE"
echo "Creating the configuration file : $CONF/$NEWCONFIGFILE" >> $DIAGOUTPUT
/bin/cp $CONF/$SCONFIGFILE $CONF/$NEWCONFIGFILE

#
# edit out any old Interphase stuff
#
ed $CONF/$NEWCONFIGFILE < $FIXFILES/fixconfig.in >>& $DIAGOUTPUT

#
# append the new Interphase support file
#
cat $OURCONFIGFILE >> $CONF/$NEWCONFIGFILE

#
# edit the 'ident' and add support for OS4 if necessary
#
ed $CONF/$NEWCONFIGFILE < $FIXFILES/fixconfig.$OS.in >>& $DIAGOUTPUT

#*****************************************************************************#
# Compare config file before and after mods and set exception if mods failed  #
#*****************************************************************************#

cmp -s $CONF/$SCONFIGFILE $CONF/$NEWCONFIGFILE
if ! ( $status ) then
    echo ""
    echo "Update of the configuration file ( $NEWCONFIGFILE ) failed"
    echo "Update of the configuration file ( $NEWCONFIGFILE ) failed" >> $DIAGOUTPUT
    echo "Update of the configuration file ( $NEWCONFIGFILE ) failed" >> $OURDIR/warning
    set EXCEPTIONS = true
endif	#compare

echo "Done with non-bootable configuration file updates" >> $DIAGOUTPUT

#*****************************************************************************#
# Normal exit from 'common' back to installation script
#*****************************************************************************#
    cd $OURDIR
    exit

#*****************************************************************************#
# Interrupt Service Routine                                                   #
#*****************************************************************************#
exitinterrupt:
    cd $OURDIR
    setenv ABORT_SCRIPT true
    exit

#*****************************************************************************#
# Fatal Error Exit Routine                                                    #
#*****************************************************************************#
fatal_error_exit:
    cd $OURDIR
    setenv FATAL_ERROR true
    exit

#*****************************************************************************#
# End of common file
#*****************************************************************************#

