#!/bin/sh

MACHINE=next

if (test $MACHINE = next)
then
   # This is valid ONLY if TRH's SysVIPC library is used.
   #
   /bin/ls -l /tmp/.Semaphores/* /tmp/.SharedMemory/* | \
   egrep "`whoami`|postgres|picasso" | \
   /bin/awk '{printf "rm -f %s\n", $NF}' - > /tmp/ipcclean.$$

elif (test $MACHINE = seq)
then
	IPCS=/usr/att/bin/ipcs
    $IPCS | egrep '^m .*|^s .*' | egrep "`whoami`|postgres|picasso" | \
    /bin/awk '{printf "/usr/att/bin/ipcrm -%s %s\n", $1, $2}' '-' > /tmp/ipcclean.$$
else
	IPCS=/usr/bin/ipcs
    $IPCS | egrep '^m .*|^s .*' | egrep "`whoami`|postgres|picasso" | \
    /bin/awk '{printf "ipcrm -%s %s\n", $1, $2}' '-' > /tmp/ipcclean.$$
fi


chmod +x /tmp/ipcclean.$$
if (test -s /tmp/ipcclean.$$)
then
	/tmp/ipcclean.$$
fi
rm -f /tmp/ipcclean.$$
