#!/bin/sh
#
# sun_plan_preinstallp
#
# Copyright (c) 2001, PerfCap Corporation, Nashua NH
# All Rights Reserved.
#
# Preinstalation script for solaris install planner
#---------------------------------------------------------------

OS="`uname -s`"
OSVER="`uname -r`"

if [ ${OS} != "SunOS" ]
then
    echo "Unsupported OS, Installation exiting..."
    return -1
fi

IMAGE=/usr/bin/pawzagent

#
# if softlink remove it
#
if [ -h ${IMAGE} ]
then
   if [ -x ${IMAGE} ]
   then
       RUN_IMAGE="`/usr/bin/pawzagent -status`"
       if [ -n ${RUN_IMAGE} ]
       then
	   echo "pawzagent running. Executing stop command..."
	   $IMAGE -stop
	   sleep 1
       fi
   fi
   rm $IMAGE
fi
#
# if image rename it
#
if  [ -f ${IMAGE} ]
then
   RUN_IMAGE="`/usr/bin/pawzagent -status`"
   if [ -n $RUN_IMAGE ]
   then
       echo "pawzagent running. Executing stop command..."
       $IMAGE -stop
       sleep 1
   fi
   echo " renaming  $IMAGE to  $IMAGE.`date +"%m%h%Y_%H%M"`"
   mv $IMAGE $IMAGE."`date +"%m%h%Y_%H%M"`"
fi
exit 0
