#!/bin/sh
# Copyright (C) 2002, 2007, Hitachi, Ltd.
# remove installation script
# Agent for Solaris

if [ ! -d /var/tmp/htm_install.lck ] ; then
    echo "Please execute uninstall.sh."
    exit 1
fi

PPNO_KIND=2

# Set environment: Variables
THIS_PP="Agent for Solaris"
THIS_SH="remove installation script"
JP1PC_HOME=/opt/jp1pc

JPCCTRL=$JP1PC_HOME/tools/jpcctrl
JPCSTOP=$JP1PC_HOME/tools/jpcstop



# Write log header
echo "> ##############################################################################"
echo "> #              :    $THIS_PP"
echo "> # Script starts: $THIS_SH"
echo "> # date:          \c"
date


# SHUTDOWN ALL HTM PROCESSES
echo "> Shutdown all Tuning Manager processes."
if [ -x $JPCCTRL ] ; then
	$JPCCTRL confirm "?*" -nolog
	RET=$?
	if   [ $RET -eq 0 ] ; then
		if [ -x $JPCSTOP ] ; then
			$JPCSTOP all "kill=180,1"
			RET=$?
			case $RET in
			1)
				$JPCSTOP all
				sleep 30
				;;
			10)
				echo ">     $JPCSTOP: Failed."
				echo "> Script failed(exit 1): $THIS_SH"
				exit 1
				;;
			*)
				sleep 15
				;;
			esac

			echo ">     $JPCSTOP: Completed."
		else
			echo ">     $JPCSTOP: No such file exists or permission was denied."
		fi
	fi
else
	echo ">     $JPCCTRL: No such file exists or permission was denied."
fi



echo "> # Script completed:  $THIS_SH"
echo "> ##############################################################################"
exit 0
