#!/bin/ksh
# Copyright 2002 AppIQ, Inc. AppIQ Proprietary All Rights Reserved.
#
set +x

status=`uname -r | grep "5.8"`
status1=`uname -r | grep "5.9"`
status2=`uname -r | grep "5.10"`


if test -z "$status" && test -z "$status1" && test -z "$status2"
then
   echo "AppIQ Solaris CIM Extensions only compatible with Solaris 5.8 or 5.9 or 5.10"
   exit 3
fi

pkglibc=`pkginfo SUNWlibC`
pkglibcf=`pkginfo SUNWlibCf` 
patch_check=`patchadd -p | grep "Patch: 112438-"`
libcstd_check=`ls /usr/lib/libCstd.so*`

if [ "$libcstd_check" = "" ]
then
  echo "ERROR:  The library /usr/lib/libCstd.so was not found and is required."
  echo "If you are running Solaris 8 check that you have installed the required patch."
  exit 3
fi

 
if [ "$pkglibc" = "" ]
then
  echo "ERROR: The required package SUNWlibC is missing from the system"
  exit 3
fi

if [ "$pkglibcf" = "" ]
then
  echo "ERROR: The required package SUNWlibCf is missing from the system"
  exit 3
fi

#Commenting out for 4.0
#if [ "$patch_check" = "" ]
#then
#  echo "WARNING: Solaris patch 112438-xx must be applied to the system for autoagent upgrade to work"
#fi

#Check for suffficient disk space for installation of APPIQ CIM Extensions
echo "Please wait... Checking the system for needed disk space...."
INSTALLDIR=`cat $1 | grep "BASEDIR" | sed 's/BASEDIR=//'`
DF_STRING=`df -k ${INSTALLDIR} `
echo "Checking ${INSTALLDIR} for 90 MB of space..."
DISK_SPACE=`echo $DF_STRING | awk '{print $11}'`
if [ $DISK_SPACE -lt 90000 ]; then
        echo "\n************ ERROR **********************"
        echo "Insufficient disk space to install APPIQ CIM Extensions at ${INSTALLDIR}"
	echo "90 MB of disk space are required to install APPIQ CIM Extensions."
        echo "Please free up space at ${INSTALLDIR} or choose another installation directory."
        echo "Exiting...."
        echo "************ ERROR **********************"
        exit 1
fi
 

