#!/bin/sh

#    SAM-QFS_notice_begin
#
#	Solaris 2.x Sun Storage & Archiving Management File System
#
#	Copyright (c) 2004 Sun Microsystems, Inc.
#	All Rights Reserved.
#
#	Government Rights Notice
#	Use, duplication, or disclosure by the U.S. Government is
#	subject to restrictions set forth in the Sun Microsystems,
#	Inc. license agreements and as provided in DFARS 227.7202-1(a)
#	and 227.7202-3(a) (1995), DRAS 252.227-7013(c)(ii) (OCT 1988),
#	FAR 12.212(a)(1995), FAR 52.227-19, or FAR 52.227-14 (ALT III),
#	as applicable.  Sun Microsystems, Inc.
#
#    SAM-QFS_notice_end

# $Id: sampkgchk,v 1.2 2004/05/07 15:47:01 jdunn Exp $

#
# sampkgchk is a script called by ChkFs to verify that all necessary
# packages are installed. A user could of installed just the root
# portion of the SAM-FS or QFS packages and then did a mount. This script
# will verify that the usr package has been installed and will also
# verify that the root and usr packages are the same version.
#

if [ -d /var/sadm/pkg/SUNWsamfsr ]; then
   VER=`grep "^VERSION" /var/sadm/pkg/SUNWsamfsr/pkginfo`
   VER1=`echo $VER | sed -e s/VERSION=//`
   VERSION=`echo $VER1 | cut -f1 -d,`
#   echo "Version of SUNWsamfsr is $VERSION"

   if [ ! -d /var/sadm/pkg/SUNWsamfsu ]; then
      echo "FATAL ERROR: The package SUNWsamfsu is not installed"
      echo "You must install SUNWsamfsu in order for SAM-FS/QFS to run correctly"
      exit 1
   else
      VER=`grep "^VERSION" /var/sadm/pkg/SUNWsamfsu/pkginfo`
      VER1=`echo $VER | sed -e s/VERSION=//`
      VERSIONU=`echo $VER1 | cut -f1 -d,`
#      echo "Version of SUNWsamfsu is $VERSIONU"

      if [ $VERSION != $VERSIONU ]; then
         echo "FATAL ERROR: SUNWsamfsr and SUNWsamfsu are incompatible"
         echo "SUNWsamfsr version - $VERSION  SUNWsamfsu version - $VERSIONU"
         echo "You must install the same version of SUNWsamfsr and SUNWsamfsu packages"
         exit 1
      fi
   fi

elif [ -d /var/sadm/pkg/SUNWqfsr ]; then
   VER=`grep "^VERSION" /var/sadm/pkg/SUNWqfsr/pkginfo`
   VER1=`echo $VER | sed -e s/VERSION=//`
   VERSION=`echo $VER1 | cut -f1 -d,`
#   echo "Version of SUNWqfsr is $VERSION"

   if [ ! -d /var/sadm/pkg/SUNWqfsu ]; then
      echo "FATAL ERROR: The package SUNWqfsu is not installed"
      echo "You must install SUNWqfsu in order for QFS to run correctly"
      exit 1
   else
      VER=`grep "^VERSION" /var/sadm/pkg/SUNWqfsu/pkginfo`
      VER1=`echo $VER | sed -e s/VERSION=//`
      VERSIONU=`echo $VER1 | cut -f1 -d,`
#      echo "Version of SUNWqfsu is $VERSIONU"

      if [ $VERSION != $VERSIONU ]; then
         echo "FATAL ERROR: SUNWqfsr and SUNWqfsu are incompatible"
         echo "SUNWqfsr version - $VERSION  SUNWqfsu version - $VERSIONU"
         echo "You must install the same version of SUNWqfsr and SUNWqfsu packages"
         exit 1
      fi
   fi
fi
