#!/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.3 2004/06/10 21:13:07 jb149512 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
	VERSION=`pkgparam SUNWsamfsr VERSION  | sed -e s/VERSION=// | cut -f1 -d,`

	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"
		echo "correctly"
		exit 1
	fi
	VERSIONU=`pkgparam SUNWsamfsu VERSION | sed -e s/VERSION=// | cut -f1 -d,`

	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"
		echo "packages"
		exit 1
	fi

elif [ -d /var/sadm/pkg/SUNWqfsr ]; then
	VERSION=`pkgparam SUNWqfsr VERSION | sed -e s/VERSION=// | cut -f1 -d,`

	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
	fi
	VERSIONU=`pkgparam SUNWqfsu VERSION | sed -e s/VERSION=// | cut -f1 -d,`

	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"
		echo "packages"
		exit 1
	fi
fi

if [ -f /etc/opt/SUNWsamfs/remote_install ]; then
    /opt/SUNWsamfs/sbin/samsyschk
fi
