#!/bin/sh
#
# %W% %E%
#
# Copyright (c) 1999 Sun Microsystems Inc.
# All Rights Reserved
#

# Allocate the rootdirectory according to installation location
[ "$ROOTDIR" = / ] && unset ROOTDIR || ROOT="-R $ROOTDIR"

# Should get these from packaging?
ETCCMS=${ROOTDIR}/etc/SUNWcms
USRCMS=${ROOTDIR}/usr/platform/SUNW,Ultra-4FT/SUNWcms
CMSCFG=$ETCCMS/.config

# Remove the extraneous cmsd binary
removef $ROOT SUNWcmscu $USRCMS/lib/cmsd || exit 1
removef $ROOT -f SUNWcmscu || exit 1

# And now the CMS configuration files
MONLCK=$ETCCMS/.locks/cmsmonitord.lock
CMSLCK=$ETCCMS/.locks/cmsd.lock

if [ -f "$MONLCK" ]
then
	KILLPID=`cat $MONLCK`
	while kill $KILLPID 2> /dev/null
	do
		sleep 2
	done
fi

if [ -f "$CMSLCK" ]
then
	KILLPID=`cat $CMSLCK`
	KILLPID=`expr "$KILLPID" : ' *\([0-9]*\)'`
	while kill $KILLPID 2> /dev/null
	do
		sleep 2
	done
fi

rm -f $CMSCFG/configfile $CMSCFG/configfile- $CMSCFG/oldconfigfile || exit 1

exit 0

