#! /bin/sh
echo "@(#)REMOVEDEV	30.1 3/13/91 AppEng/SCCS Interphase"
#
# Interphase Corporation Northern CA. Standards for Coding based on
# DOD-STD-2167A ( Draft )
#
# ABSTRACT : REMOVEDEV is a script that will remove Interphase /dev special
#	device entries, ie. removes the device name.

# KEYWORDS : REMOVEDEV,  IPinstall
#

# CONTENTS 
#
#                  Ident        Date            Author
# -------------------------------------------------------------------------
# Designed By :    X00.00			Dan Nindorf and William Perry
#						based on "IPLOAD.SUN"
# Coded By  : Robert Hogue (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.
#  4.00 08-22-90 Rogue    added support for new multi Jaguar driver
#  3.01 07-24-90 Rogue    corrected bugs that failed to remove the Jaguar
#                         special devices (rsvj) and the 4201 SCSI tape
#                         devices (it??)
#  3.00 10-30-89 Rogue    changed the manner in which deletions are done.  If
#                         a file does not exist no message is printed.
#                         Previously a message was printed even though nothing
#                         was removed.
#  2.02 06-22-89 Rogue    changed the handling of V/SIO removals again
#  2.01 05-18-89 Rogue    changed the handling of V/SIO removals
#  2.00 05-02-89 Rogue    changed the V/SIO naming convention per STREAMS
#  1.04 04-09-89 Rogue    added support for alternate character devices (cui0/1)
#  1.03 03-23-89 Rogue    changed the syntax slightly for the 'it' entry
#  1.02 03-09-89 Rogue    added additional comments
#  1.01 03-06-89 Rogue    changed the syntax of the 'it' and 'tp' entries
#  1.00 03-01-89 Rogue    added this header
#

# Examples of Usage : REMOVEDEV ip0 ip1 is0 tp00 vj1 vj0 vt4 vt11
#

# Parameter Description :  command line parameters are Interphase device names
#

# Special Design Considerations :
#

# External Units Accessed :  ( Called, Imported, WITHed, referenced )
#
#     Unit Name                        Purpose
#-------------------------------------------------------------------------
# REMOVEDEV is called by fixdev to remove /dev entries

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

#       Interphase REMOVEDEV
#
#  This shell script removes old device entries
#
# Tapes:
#       tp*     VTAPE 1/2" tape
#	it*	V/ESDI Panther Daughter card
#	vt*     V/SCSI  4210 Jaguar tape
# Disks:
#       ip*     Interphase 2180
#	is*	V/ESDI Panther Daughter card
#       vj*     Interphase 4210 V/SCSI JAGUAR disks
# Terminal multiplexors:
#       vs*     VSIO serial ports
#	cu*	V/SIO alternate character devices for modems on ports 0, 1
umask 77

PWD=`pwd`
for i
do
case $i in

it*)
        cntlr=`expr $i : '..\(.\)'`
        unit=`expr $i : '...\(.\)'`
	name=it
	for j in 0 1 2
	do
	    if [ -b $name${cntlr}${unit}$j ]; then
               /bin/rm -f $name${cntlr}${unit}$j
	    fi
	    if [ -c r$name${cntlr}${unit}$j ]; then
               /bin/rm -f r$name${cntlr}${unit}$j
	    fi
	done	    
        ;;

vt*)
        unit=`expr $i : '..\(.*\)'`
       	name=vt
	if [ -c rs$name${unit} ]; then
           /bin/rm -f rs$name${unit}
	fi
	for j in 0 1 2
	do
	    if [ -b $name${unit}$j ]; then
               /bin/rm -f $name${unit}$j
	    fi
	    if [ -c r$name${unit}$j ]; then
               /bin/rm -f r$name${unit}$j
	    fi
	done	    
        ;;
  
 tp*)
        cntlr=`expr $i : '..\(.\)'`
        unit=`expr $i : '...\(.\)'`
	name=tp
	for j in 0 1 2 4 8
	do
	    if [ -b $name${cntlr}${unit}$j ]; then
               /bin/rm -f $name${cntlr}${unit}$j
	    fi
	    if [ -c r$name${cntlr}${unit}$j ]; then
               /bin/rm -f r$name${cntlr}${unit}$j
	    fi
	done	    
        ;;
  
is*|ip*)
        unit=`expr $i : '..\(.*\)'`
	case $i in
		is*) name=is;;
        	ip*) name=ip;;
	esac
	for j in a b c d e f g h
	do
	    if [ -b $name${unit}$j ]; then
               /bin/rm -f $name${unit}$j
	    fi
	    if [ -c r$name${unit}$j ]; then
               /bin/rm -f r$name${unit}$j
	    fi
	done
        ;;

# USAGE:       REMOVEDEV cuN
#       where  N is the controller number starting at Zero (0)
#       Syntax :  REMOVEDEV cu0
#           Removes :  cui0, cui1
#
cu*)
        unit=`expr $i : '..\(.*\)'`
        name=cui
	for j in 0 1
	do
	    if [ -c  cui`expr $unit '*' 8 + $j` ]; then
		/bin/rm -f cui`expr $unit '*' 8 + $j`
	    fi
	done
        ;;

# USAGE:       REMOVEDEV vsN
#       where  N is the controller number 0..3
#       Syntax :  REMOVEDEV vs0 vs1
#           Removes :  ttyi0, tty1, tty2,... tty31
#
vs*)
        unit=`expr $i : '..\(.*\)'`
        device=vs
        name=ttyi
	for j in 0 1 2 3 4 5 6 7
	do
	    if [ -c ${name}`expr $unit '*' 8 + $j` ]; then
        	/bin/rm -f ${name}`expr $unit '*' 8 + $j`
	    fi
	done
     ;;
 
vj*)
        unit=`expr $i : '..\(.*\)'`
	name=vj
        if [ -c rs$name${unit} ]; then
            /bin/rm -f rs$name${unit}
        fi
	for j in a b c d e f g h
	do
	    if [ -b $name${unit}$j ]; then
		/bin/rm -f $name${unit}$j 
	    fi
	    if [ -c r$name${unit}$j ]; then
		/bin/rm -f r$name${unit}$j 
	    fi
	done
        ;;

local)
        sh REMOVEDEV.local
        ;;

*)
        echo "I don't know how to REMOVEDEV $i."
        ;;
esac
done
