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

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

if [ $OS != "SunOS" ]
then
    echo "eCAP Monitor supports Solaris 5.7 - 5.10"
    echo "Unsupported OS, Installation exiting...
    return -1
fi

if [ ${OSVER} != "5.11" ] && [ ${OSVER} != "5.7" ] && [ ${OSVER} != "5.8" ]  && [ ${OSVER} != "5.9" ] && [ ${OSVER} != "5.10" ]
then
    echo "eCAP Monitor supports Solaris 5.7 - 5.10"
    echo "Unsupported OS version, Installation exiting...
    return -1
fi

IMAGE=/usr/bin/pawzrta
#
# if softlink remove it
#
if [ -h ${IMAGE} ]
then
    if [ -x ${IMAGE} ]
    then
       RUN_IMAGE="`pawzrta -status`"
       if [ -n ${RUN_IMAGE} ]
       then
	   echo "PAWZrta 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/pawzrta -status`"
   if [	 -n ${RUN_IMAGE} ]
   then
       echo "PAWZrta 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
