#! /bin/sh
#
# @(#)objectexists	1.3	LPS_UNX_COM	2/19/95
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# objectexists
#
# This script is used to determine if the named object of the specified
# class exists in the LPS Object Database.
#
# Parameters:
#    $1 - Class identifier, one of {ENV, MC, PC, PS}
#    $2 - The name of the object, should be null for ENV class
#
# Global variables:
#    LPSODB
#    LPSODBLIST
#    TMPDIR
#
# Exit value is 0 if the object exists, 1 if it was not found in the
# $LPSODB file.  Otherwise, "badodb" is called to signal the end of the
# procedure.

odberrs=$TMPDIR/odberrs.$$

class=$1
name=$2

case "$class" in
    ENV ) opt="-e" ; name="" ;;
    MC  ) opt="-m" ;;
    PC  ) opt="-p" ;;
    PS  ) opt="-s" ;;
esac

$LPSODBLIST -f $LPSODB $opt $name 1> /dev/null 2> $odberrs
case "$?" in
    0) rc=0 ;;			# Object does exist
    4) rc=1 ;;			# Object was not found
    *) badodb $odberrs		# Should force script termination...
       exit $? ;;		# In case badodb returns, use its value
esac

rm -f $odberrs   # Cleanup temporary file

exit $rc
