#!/bin/sh
#
# Copyright 04/22/98 Sun Microsystems, Inc.  All rights reserved.
#
# @(#)prebackout	1.1 98/04/22 Sun Microsystems, Inc.
#

debug_device=/dev/null;  export debug_device
ECHO=/bin/echo

getpid()
{
    short_daemon=`echo $1 | cut -b-8`
    /usr/bin/ps -e | /usr/bin/grep "$short_daemon\$" | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'
}

killprocs() {

  for daemon in em_login em_ncam em_cmip em_mis em_snmp- em_snmfwd em_autod \
            em_datad em_nnmpa em_dmuxd
  do
     pid=`getpid $daemon`
   
     for p in $pid; do
            /usr/bin/kill $1  $p > $debug_device 2>&1
     done
  done

  /usr/bin/rm -f /tmp/sysmgr.pids /tmp/dmuxd.pid

  if /usr/bin/pkginfo -q SUNWsnmag ; then
        $installdir/SUNWconn/em/bin/snm_kill -A > $debug_device
  fi
}

#
# If the MIS is installed on this machine, then stop it before applying
# the patch.
#

if /usr/bin/pkginfo -q SUNWemmis; then
    installdir=`/usr/bin/pkgparam SUNWemmis BASEDIR`

    killprocs
fi

exit 0

