#! /bin/sh
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#

#This script checks if the IPC ID exists. If it exists then it removes
#the IPC based on the type and the key of the IPC  

OS_PLATFORM=`uname`

#
# Solaris looking for IPC id in decimal
# Other platforms looking for IPC key which is in hex
#
if [ "$OS_PLATFORM" = "SunOS" ]
then
    Output=`/usr/bin/ipcs | grep $1`
else
    Output=`/usr/bin/ipcs | grep 0x$1`
fi

if [ $? -eq 0 ]
   then
   Ipc=`echo $Output | awk '{print $1}'`
   Key=`echo $Output | awk '{print $2}'`
   echo "KIX562I: Removing IPC $Ipc $Key"
   /usr/bin/ipcrm -$Ipc $Key
fi
