#!/bin/sh
# =====================================================================         
# PROPRIETARY-STATEMENT:                                                        
# Licensed Material - Property of IBM                                           
#                                                                               
# 5724-I63, 5724-H88, 5655-N01, 5733-W61                                        
# (C) Copyright IBM Corp. 1999, 2013                                            
# All Rights Reserved                                                           
# US Government Users Restricted Rights - Use, duplication or                   
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.             
# =====================================================================         
<!-- import documents/data/buildInfo.script -->
# =====================================================================        
#                                                                               
# Creates the secure proxy server profile.                    
#                                                                              
# =====================================================================        
<!--  Change Activity:                                                -->         
<!--                                                                  -->         
<!-- F908-33863.1 V8.0 20101005 PDOP: Initial version                 -->
<!-- 676719      V8.0  20101102 PDOP: Escape response file values     -->
<!-- 687021      V8.0  20110121 PDOP: Verify script file exists       -->
<!-- 739067    V8.5.5  20121114 PDOP: TMPDIR support(renamed BBO855PA)-->
<!-- ================================================================ -->

# Gets path of temporary work directory
workDirPath=$(dirname "$0")
echo "Work directory path is $workDirPath"

# Verifies that the create profile script exists
if [[ ! -f '${zConfigMountPoint}/${zWasServerDir}/bin/zCreateProfile.sh' ]]; then
	echo 'ERROR: The bin/zCreateProfile.sh file does not exist within the'
	echo '       specified WebSphere Application Server for z/OS configuration image:'
	echo '       ${zConfigMountPoint}/${zWasServerDir}'
	echo '       Most likely the configuration image path is not correct or the'
	echo '       customization jobs have not been run in the correct order.'
	exit 8
fi

# Creates manage profiles log directory if it does not already exist
logDirectory='${zConfigMountPoint}/${zWasServerDir}/logs/manageprofiles'
if [[ ! -e "$logDirectory" ]]; then
	echo Creating the manage profiles log directory
	mkdir -p "$logDirectory"
	rc="$?"
	if [ "$rc" -ne 0 ]; then
		exit rc
	fi
fi

# Copies ports file to manage profiles log directory
echo Copying the ports file to the manage profiles log directory
cp  "$workDirPath"'/bbowaspf' "$logDirectory"/_portdef.props 
rc="$?"
if [ "$rc" -ne 0 ]; then
    exit $rc
fi

# Invokes script to create the profile
echo Creating the profile
'${zConfigMountPoint}/${zWasServerDir}/bin/zCreateProfile.sh' \
 -configRoot '${zConfigMountPoint}/${zWasServerDir}' \ 
 -configOwner '${zAdminUserid}' \
 -responseFile "$workDirPath"'/bbowresp'
rc="$?" 
 
exit "$rc"
                                                                              
