#!/bin/sh
# $Id: ob.checkinstall,v 3.18 2002/07/11 14:14:25 yalla Exp $  - %Q%
#ident "%Z%isis:$RCSfile: ob.checkinstall,v $ $Revision: 3.18 $"

# Copyright(C)2000 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
# UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
# LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
# IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
# OR DISCLOSURE.
# 
# THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
# TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
# OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
# EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
# 
#               RESTRICTED RIGHTS LEGEND
# USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
# SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
# (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
# COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
#               VERITAS SOFTWARE
# 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043

#
# Perform checkinstall processing for the ISIS package.
#

PATH="/usr/sadm/bin:/sbin:/usr/sbin:/usr/bin:/bin:$PATH"
REVISION=3.0.2.272
OS_VERSION=`eval uname -r | sed 's/^5\./2./'`
JUMPSTART_PATH="/"

UNINSTALLVRTSOBDEV="Please uninstall VRTSobdev package, before installing VRTSob pkg"
INCOMPLETEINSTALL="You have an incomplete installation of VRTSob on your system. Please remove it before installing this version of VRTSob"
FOUND_VEA="Found VRTSob $revision"
NEWERVERAVAILABLE="A newer version of VRTSob is already installed"
SAMEVER="is already installed."
STOPSRV="Please stop the VEA server"
CONINSTALL="Continuing with installing VRTSob"
USEADMINFILE="You need to use the VRTSobadmin file provided"

#
# If BASEDIR parameter is modified in request script, the modified value
# is not available here.
#
# $PKG_INSTALL_ROOT is nothing when user does not specify -R "root_dir".
# In preintsall, postinstall, preremove, postremove scripts $BASEDIR is
# $PKG_INSTALL_ROOT$CLIENT_BASEDIR.
# For example, if $PKG_INSTALL_ROOT is root_dir, $CLIENT_BASEDIR is
# /opt/VRTSob, then $BASEDIR is root_dir/opt/VRTSob.
#

#
# It should be noted that $BASEDIR and $CLIENT_BASEDIR are /opt/VRTSob in
# request and checkinstall scripts irrespective of $PKG_INSTALL_ROOT existance.
# By the time preinstall, postinstall, preremove and postremove scripts
# are executed BASEDIR itself is relocated to $PKG_INSTALL_ROOT and takes
# on the value $PKG_INSTALL_ROOT$BASEDIR. Where as $CLIENT_BASEDIR is same
# as erlier $BASEDIR.
#



    if [ "X$PKG_INSTALL_ROOT" != "X" ]
    then
        JUMPSTART_PATH="$PKG_INSTALL_ROOT"
    fi


   #
   # Check if VRTSobdev package is installed.
   #
   if pkginfo -R $JUMPSTART_PATH -q VRTSobdev 2>/dev/null
   then
       errstr -e "$UNINSTALLVRTSOBDEV"
       exit 3
   fi


   #
   # Check if an VRTSob package is already installed.
   #

   if pkginfo -R $JUMPSTART_PATH -l VRTSob 2>/dev/null >/dev/null
   then

#       INSTANCE=`echo $PKGINST | sed -e s#VRTSob##g`
#       echo $INSTANCE
#       if [ "X$INSTANCE" != "X" ]

# UPDATE variable is set to "yes" when a package is overwritten. 

       if [ "X$UPDATE" != "Xyes" ]
       then
           errstr -e "$USEADMINFILE"
           exit 3
       fi

       if pkginfo -R $JUMPSTART_PATH -il VRTSob 2>/dev/null >/dev/null
       then
           echo ""
       else
           errstr -e "$INCOMPLETEINSTALL"
           exit 3
       fi

       revision=`pkgparam -R $JUMPSTART_PATH VRTSob REV` 2>/dev/null


       #
       # Check if a newer package is already installed.
       #
       if expr "$revision" \> "$REVISION" >/dev/null
       then
          errstr -e "$FOUND_VEA $revision $NEWERVERAVAILABLE"
          exit 3
       fi

       #
       # Check if same package is already installed.
       #
       if expr "$revision" = "$REVISION" >/dev/null
       then
          puttext -l 5 "$revision $SAMEVER"
          exit 3
       fi

       #
       # Check if vxsvc is running
       #
       serviceRunning=1
       [ -f $PKG_INSTALL_ROOT/var/vx/isis/vxisis.lock ] || serviceRunning=0
       if [ $serviceRunning -eq 1 ] >/dev/null
       then
             errstr -e "$STOPSRV"
             exit 3
       fi
       
       echo "PREVIOUS_INSTALL=yes" > $1
   else
       echo "PREVIOUS_INSTALL=no" > $1 
   fi


puttext -l 5 "$CONINSTALL $REVISION"

exit 0


