#!/bin/csh -f
echo "@(#)fixfstab	30.1 3/13/91 AppEng/SCCS Interphase"
#
# Interphase Corporation Northern CA. Standards for Coding based on
# DOD-STD-2167A ( Draft )
#
# ABSTRACT : fixfstab attempts to create a bootable version of the /etc/fstab
# 	file.

# KEYWORDS : fixfstab
#

# CONTENTS 
#
#                  Ident        Date            Author
# -------------------------------------------------------------------------
# Designed By :    X00.00	3-1-89		Robert Hogue (rogue)
# Coded By  : rogue
# Tested By : rogue on SUN3/160 using Sun OS3.5 and OS4.0 only

# Revision History :
#
# Rev#  Date     Author   Change
#--------------------------------------------------------------------------
# 30.1  03-13-91 rbrant   New development/distribution format.
#  3.01 04-18-90 rogue    added support for 4410 'vj' boot device
#  3.00 08-15-89 rogue    added support for 4401 'is' boot device
#                         changed the number of arguments to 3
#  2.00 04-05-89 rogue    added a test to see if 'ip' entries are in the fstab
#                         file before doing any edits.
#  1.02 03-09-89 rogue    added additional comments
#  1.01 03-02-89 rogue    added 'setenv' for FIXFILES
#  1.00 03-01-89 rogue    added this header
#

# Note : fixfstab assumes that you are creating an Interphase disk.
# To create a new disk you are either in emulation mode in which case
# the "from" device is 'xy0a' OR you are copying from some Sun device (like
# 'xd0a') to the new Interphase disk, the "to" device (like ip0 or is0).

# Examples of Usage : fixfstab file from to
#	where : 'file' is the file to modify (usually /etc/fstab )
#		'from' is the SUN device the files were copied from.
#	 	       legal values for 'from' are 'xd0a', 'xy0a', 'sd0a'
#            OR 'from' is the Xylogics emulation device 'xy0a'
#		'to'   is the new Interphase bootable disk device
#		       legal values for 'to' are 'ip0a', 'vj10a' and 'is0a'
#		       although no range checking is done on these values.

# Special Design Considerations :
#

# External Units Accessed :  ( Called, Imported, WITHed, referenced )
#
#     Unit Name                        Purpose
#-------------------------------------------------------------------------
# $AWKFILES, $FIXFILES are environmental variables defined in IPinstall
# dumpIP                 calls fixfstab (dumpIP will also set environment)
# fix/fixfstab.sd0a.ip0a.in   'ed' input file for copies from 'sd0a' to 'ip0a'
# fix/fixfstab.xy0a.ip0a.in   'ed' input file for copies from 'xy0a' to 'ip0a'
# fix/fixfstab.xd0a.ip0a.in   'ed' input file for copies from 'xd0a' to 'ip0a'
#
# fix/fixfstab.sd0a.is0a.in   'ed' input file for copies from 'sd0a' to 'is0a'
# fix/fixfstab.xy0a.is0a.in   'ed' input file for copies from 'xy0a' to 'is0a'
# fix/fixfstab.xd0a.is0a.in   'ed' input file for copies from 'xd0a' to 'is0a'
#
# fix/fixfstab.sd0a.vj10a.in   'ed' input file for copies from 'sd0a' to 'vj10a'
# fix/fixfstab.xy0a.vj10a.in   'ed' input file for copies from 'xy0a' to 'vj10a'
# fix/fixfstab.xd0a.vj10a.in   'ed' input file for copies from 'xd0a' to 'vj10a'
# awkfiles/fstab.awk     tests for 'ip0', vj10, or 'is0' entries in fstab


# Exceptions and the Conditions which will raise them :
#

# 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
#-----------------------------------------------------------------------
#

#===========================================================================#
#
# Strings
#
#
set noglob
set prompt = '=====> '
set true = 1
set false = 0

#===========================================================================#

if !($#argv == 3) then
	echo "usage: fixfstab file from to"
	exit
endif

#
# test to see if there is already an entry for 'ip0' or 'is0' in fstab
# 
set tst = `awk -f $AWKFILES/fstab.awk $1`

#
# modify the file if above test fails.. 0=no ip/is entry present,  1= present
#
if($tst == 0) then
    #
    # edit the file to add Interphase support
    #
    if ! ( -e $FIXFILES/fixfstab.$2.$3.in ) then
	echo ""
	echo "A fix for fstab is not available for $2 to $3"
	echo "You must make any desired changes by hand."
	echo "The file $FIXFILES/fixfstab.$2.$3.in was not found."
    else
	ed $1 < $FIXFILES/fixfstab.$2.$3.in>&/dev/null
    endif
else
    echo ""
    echo "Interphase support already present in '$1'.. no modifications made"
endif
exit	#fixfstab

