#!/bin/sh 
# This script does post remove tasks for
# the Seabreeze installation.
#
# Copyright (c) 1998 by Sun Microsystems, Inc.
# All rights reserved.
#
# @(#)postremove	1.6     06/04/99
#

#########################################################################
# Set version subdirectory and configuration paths

VERSDIR="3_0"
SEAETCROOT="/etc/opt/SUNWseam" 
SEAVARROOT="/var/opt/SUNWseam" 
SEAROOT="${BASEDIR}/SUNWseam"

SEABASEDIR="${SEAROOT}/${VERSDIR}"
SEAETCDIR="${SEAETCROOT}/${VERSDIR}"
SEAVARDIR="${SEAVARROOT}/${VERSDIR}"

SEASVRPROPS=server/AdminServer.properties
LOGNAMEPROP=admin.logging.file.name
LOGDIRPROP=admin.logging.file.dir

#########################################################################
# Remove our configuration files and subdirectories
# The directory for log files may have been reset by Log Viewer
# If so, remove just our logs from that directory.

echo "Removing configuration, scopes, and log subdirectories..."
SVRPROPS=${SEAETCDIR}/${SEASVRPROPS}
if [ -f ${SVRPROPS} ]; then
	LOGNAME=`/usr/bin/grep ${LOGNAMEPROP} ${SVRPROPS} | /usr/bin/cut -f2 -d=`
	LOGDIR=`/usr/bin/grep ${LOGDIRPROP} ${SVRPROPS} | /usr/bin/cut -f2 -d=`
	if [ "${LOGNAME}" != "" -a "${LOGDIR}" != "" ]; then
		rm -f ${LOGDIR}/${LOGNAME}*
	fi
fi

if [ -d ${SEAETCDIR} ]; then
   rm -rf ${SEAETCDIR} >/dev/null 2>&1
fi
if [ -d ${SEAVARDIR} ]; then
   rm -rf ${SEAVARDIR} >/dev/null 2>&1
fi

#########################################################################
# If we are the last version, remove the SUNWseam subdirectory
# from the etc and var opt directories

EMPTY=`ls ${SEAETCROOT}` >/dev/null 2>&1
if [ "${EMPTY}" = "" ]; then
   echo "Removing ${SEAETCROOT}"
   rmdir ${SEAETCROOT} >/dev/null 2>&1
fi

EMPTY=`ls ${SEAVARROOT}` >/dev/null 2>&1
if [ "${EMPTY}" = "" ]; then
   echo "Removing ${SEAVARROOT}"
   rmdir ${SEAVARROOT} >/dev/null 2>&1
fi

#########################################################################
# Remove the init.d start/stop script and links for just this version

echo "Removing daemon start/stop script and links..."
if [  -f /etc/rc3.d/S83admsvr${VERSDIR} ]
  then
    rm -f /etc/rc3.d/S83admsvr${VERSDIR} >/dev/null 2>&1
fi

if [ -f /etc/rc3.d/K83admsvr${VERSDIR} ]
  then
    rm -rf /etc/rc3.d/K83admsvr${VERSDIR} >/dev/null 2>&1
fi

if [ -f /etc/init.d/admsvr${VERSDIR} ]
  then
    rm -f /etc/init.d/admsvr${VERSDIR} >/dev/null 2>&1
fi

echo "AdminSuite removal complete"
exit 0   
