#!/usr/bin/ksh93
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# 61haes_r714 src/43haes/usr/sbin/cluster/sa/db2/sbin/cl_db2discovery_env.sh 1.3 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2005,2006 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
# @(#)35	1.3 src/43haes/usr/sbin/cluster/sa/db2/sbin/cl_db2discovery_env.sh, hacmp.assist, 61haes_r714 2/12/06 23:58:30

##
## NAME:
##		cl_db2discovery_env
##
## DESCRIPTION:
##		This script is called to determine the usreprofile environment
##		variables, specifically ARCHIVE_PATH, and AUDIT_ERROR_PATH
##		for volume group discovery
##
##		Note: This script is only called via cl_db2discovery, on the local
##		node.  cl_db2discovery does not perform this operation because it
##		would potentially run into namespace issues with the running
## 		environment.
##		
##
## ARGUMENTS:
##		-P UserProfilePath
##		   
## RETURN:
##		0 on success
##		1 or higher on failure
##
##---------------------------------------------------------------------------

# Read in the DB2 smart assistant definitions
. /usr/es/sbin/cluster/sa/db2/etc/db2_definitions

if set -- $(getopt P:U: $* 2>&1); then

        while [ $# != 0 ]; do
                case "$1" in
			-P)
				PROFILE_PATH=$2
				shift
			;;
                esac
                shift
        done
fi

if [[ -z $PROFILE_PATH ]]; then
	exit 1
fi

DB2PROFILE=$PROFILE_PATH/sqllib/db2profile
DB2USERPROFILE=$PROFILE_PATH/sqllib/userprofile

if [[ -f $DB2PROFILE ]]; then
	# This should read in the $PROFILE_PATH/sqllib/db2profile file
	# As DB2 sources this file, we'll do it here anyway
	. $PROFILE_PATH/sqllib/db2profile
else
	# Inform cl_db2discovery we were unable to source the profile
	exit 1
fi

# User defined environment variables, if this fails its not as important
# we'll cleanly exit even if we can't read this file
[[ -f $DB2USERPROFILE ]] && . $PROFILE_PATH/sqllib/userprofile

# Now report the variable names, and there values
for var in $DB2_DBM_ENVIRONMENT_VARIABLES; do
	typeset -n val=$var
	echo "$var=${val}"
done

