#!/bin/sh
# $Id: postremove,v 1.1.2.2 2005/04/08 20:52:46 rs131644 Exp $
# postremove - postremove script for scs

SCSHOME=/scs

RM=/bin/rm
RMDIR=/bin/rmdir

#
# fuctions
#

printInfo() {
    echo "Info: $@"
}


#
# Main
#

#
# remove various SCS directories
#
printInfo "Removing left over directories and files"

$RM -rf /var/log/mgmt /var/tmp/am /var/tmp/am_mail_ignore 
$RM -f /etc/cron.d/mgmtScheduler

#
# Tomcat stuff
#
$RM -f /var/tomcat4/modules /var/tomcat4/conf/httpd.conf
$RM -rf /var/tomcat4/webapps/sdui /var/tomcat4/web

TOMCATDIRS="cgi-bin webapps"

if [ "$REMOVE_TOMCAT" = "$TRUE" ]; then
  $RM -rf /var/log/tomcat4 /var/cache/tomcat4 /var/lock/subsys/tomcat4 \
          /var/run/tomcat4.pid
  TOMCATDIRS="$TOMCATDIRS server"
fi

for TOMCATDIR in $TOMCATDIRS
do
   find "/var/tomcat4/$TOMCATDIR" -depth -type d -exec $RMDIR {} \;
done

$RMDIR /var/tomcat4 > /dev/null 2>&1

#
# Clean up the /scs directory tree
#

if [ "$REMOVE_SCSLOGS" = "$TRUE" ] ; then 
   $RM -rf $SCSHOME/logs
fi

if [ "$REMOVE_SCSBACKUPS" = "$TRUE" ] ; then 
   $RM -rf $SCSHOME/backups
fi

if [ "$REMOVE_SCSKEYPAIR" = "$TRUE" ] ; then
    $RM -f $SCSHOME/etc/ssh/csid_rsa $SCSHOME/etc/ssh/csid_rsa.pub
fi

# Remove the approved host list

$RM -f $SCSHOME/etc/ssh/ssh_known_hosts

# Remove the automatic backup of task_exec.conf provided by RPM

$RM -f $SCSHOME/etc/task_exec.conf.rpmsave

# Remove uninstaller itself

$RM -rf $SCSHOME/uninstall

for SCSDIR in backups bin clientRpms data diag etc lib mappScripts msRpms sbin share
do
  if [ -d "$SCSHOME/$SCSDIR" ] ; then
      find "$SCSHOME/$SCSDIR" -depth -type d -exec $RMDIR {} \; 2> /dev/null
  fi
done

$RM -f $SCSHOME/license_agreement $SCSHOME/README

if [ "$REMOVE_SCSBASE" = "$TRUE" ] ; then
    $RM -rf $SCSHOME
fi

$RMDIR $SCSHOME 2> /dev/null

$RMDIR /etc/java 2> /dev/null 

$RM -rf /etc/build

exit 0
