#!/bin/sh
# Copyright 04/03/96 Sun Microsystems, Inc. All Rights Reserved.
#
#pragma ident  "@(#)preremove	1.2 96/04/03 Sun Microsystems"
#
# preremove: Network Management Daemons
#
# Exit codes for installation scripts
e_ok=0
e_fatal=1      # stop installation on this exit
e_warning=2    # Installation will go on.
e_int=3        # Interrupted. Stop installation
e_reboot=10    # User must reboot after installation of all selected packages
e_rebootnow=20 # User must reboot right after installation of current package
               # To be added to one of the single-digit exit code above

# Trap interrupt
trap `exit $e_int` 15

#
# kill running Solstice Enterprise Manager daemons
#
killproc() {
    long_proc=`echo $1 | fold -8`
    for proc in $long_proc; do break; done

    pid=`/usr/bin/ps -e | /usr/bin/grep -w $proc | 
	 /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
    for p in $pid
    do
          echo "Terminating $1 PID=$p "
          if [ "$1" != "em_snmp-trap" ] ; then
              kill -9 $p
          else
              kill -15 $p
          fi
    done
}

#
# kill all the running Solstice Enterprise Manager daemons
#
echo "Terminating any running Solstice Enterprise Manager Daemon processes."

killproc em_snmp-trap


# End
exit $e_ok

