#!/bin/sh
#
# Copyright 04/14/98 Sun Microsystems, Inc.  All rights reserved.
#
# # @(#)prebackout	1.5 99/07/27 Sun Microsystems, Inc.
#

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

PATH=/usr/bin:/bin

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

    #
    # Shut down the MIS, related daemons, and processes.
    #

    $installdir/SUNWconn/em/bin/em_services -force -stop

    #
    # Remove the NerveCenter templates saved previously with this patch.
    #
    rm -rf /tmp/*106000-07

    #
    # Remove the NerveCenter templates saved previously with this patch.
    #

    if [ -d $installdir/SUNWconn/em/install/nc_templates.orig ]
    then

	echo "Removing standard Nerve Center templates in $installdir/SUNWconn/em/install/nc_templates.orig previously saved by this patch."
	echo "...copying to /tmp/nc_templates.orig.106000-07."
	cp -r $installdir/SUNWconn/em/install/nc_templates.orig \
				/tmp/nc_templates.orig.106000-07
	rm -rf $installdir/SUNWconn/em/install/nc_templates.orig
    fi

    if [ -d $installdir/SUNWconn/em/etc/misc_templates.orig ]
    then

	echo "Removing miscellaneous Nerve Center templates in $installdir/SUNWconn/em/etc/misc_templates.orig previously saved by this patch."
	echo "...copying to /tmp/misc_templates.orig.106000-07."
	cp -r $installdir/SUNWconn/em/etc/misc_templates.orig \
				/tmp/misc_templates.orig.106000-07
	rm -rf $installdir/SUNWconn/em/etc/misc_templates.orig
    fi

fi

#
# Bug 4096728: make sure that any customizations made in S98cmipmpa stay.
#

if pkginfo -q SUNWemcpa; then
    default_host=`grep '^EM_MIS_DEFAULT_HOST' /etc/rc2.d/S98cmipmpa |
		  sed -e 's/.*:-//' -e 's/}"$//'`
    mis_port=`grep '^EM_MIS_DEFAULT_PORT' /etc/rc2.d/S98cmipmpa |
	      sed -e 's/.*:-//' -e 's/}"$//'`
    mpa_port=`grep '^EM_CMIP_MPA_DEFAULT_PORT' /etc/rc2.d/S98cmipmpa |
	      sed -e 's/.*:-//' -e 's/}"$//'`
   
    if [ "$default_host" != "localhost" -o \
	 "$mis_port" -ne 5555 -o \
	 "$mpa_port" -ne 5557 ] ; then
	rm -rf /tmp/*106000-02			# paranoid
	echo $default_host > /tmp/host.106000-02
	echo $mis_port > /tmp/mis_port.106000-02
	echo $mpa_port > /tmp/mpa_port.106000-02
    fi
fi

if /usr/bin/pkginfo -q SUNWemapp; then
    rm -rf $installdir/SUNWconn/em/config/discover.conf.106000-07
fi

exit 0
