#! /bin/sh
#
# Copyright (c) 1997-2002 Silicon Graphics, Inc.  All Rights Reserved.
#
# Cleanup my seamphores and shared memory segments ... leave
# smh segment id 0, things owned by root and/or Oracle
#

# Get standard environment
. $PCP_DIR/etc/pcp.env

if [ $PCP_PLATFORM = irix ]
then
    ipcrm `ipcs -ms | $PCP_AWK_PROG '
$5 == "root"		{ next }
$5 == "oracle"		{ next }
$5 == "sybase"		{ next }
$5 == "informix"	{ next }
/^m/		{ if ($2 != 0) printf "-m %d ", $2 }
/^s/		{ printf "-s %d ", $2 }
END		{ print "" }'`
elif [ $PCP_PLATFORM = linux ]
then
    ipcs -ms | $PCP_AWK_PROG '
$5 == "root"		{ next }
$5 == "oracle"		{ next }
$5 == "sybase"		{ next }
$5 == "informix"	{ next }
/^m/		{ if ($2 != 0) print "shm %d", $2 }
/^s/		{ print "sem %d", $2 }' \
    | while read args
    do
	ipcrm $args
    done
else
    bozo! - how do you do this ipc stuff
fi

exit 0
