#!/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 procs for the deployment manager and application server
# nodes.                    
#                                                                              
# =====================================================================        
<!--  Change Activity:                                                -->         
<!--                                                                  -->         
<!-- F908-33863  V8.0  20100913 PDOP: Initial version                 -->
<!-- 676719      V8.0  20101102 PDOP: Escape response file values     -->
<!-- 677421      V8.0  20101108 PDOP: Use zCopyFilesToPds.sh for copy -->
<!-- 730602      V8.5  20120314 PDOP: Delete admin async proc         -->
<!-- 739067    V8.5.5  20121113 PDOP: TMPDIR support(renamed BBO855RC)-->
<!-- ================================================================ -->

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

# Deletes directory to collect the customized procs
echo 'Deleting the directory to collect the customized procs (if it already exists)'
if [[ -d "$workDirPath"'/procs' ]]; then
    rm -R "$workDirPath"'/procs'
    rc="$?" 
    if [ "$rc" -ne 0 ]; then
        exit "$rc"
    fi
fi

# Creates empty directory to collect the customized procs
echo Creating empty directory to collect the customized procs
mkdir "$workDirPath"'/procs' 
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Invokes script to build the deployment manager control region proc
echo Building deployment control region proc
'${zSmpePath}/bin/zCreateProc.sh' \
 -procName '${zControlProcName}' \
 -procType DCR \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zConfigMountPoint}' \
 -wasServerDirectory '${zWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Invokes script to build the deployment manager servant region proc
echo Building deployment manager servant region proc
'${zSmpePath}/bin/zCreateProc.sh' \
 -procName '${zServantProcName}' \
 -procType DSR \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zConfigMountPoint}' \
 -wasServerDirectory '${zWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Invokes script to build the daemon proc
echo Building daemon proc
'${zSmpePath}/bin/zCreateProc.sh' \
 -procName '${zDaemonProcName}' \
 -procType DMN \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zConfigMountPoint}' \
 -wasServerDirectory '${zWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Invokes script to build the application server control region proc
echo Building application server control region proc
'${zAppServerSmpePath}/bin/zCreateProc.sh' \
 -procName '${zAppServerControlProcName}' \
 -procType ACR \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zAppServerConfigMountPoint}' \
 -wasServerDirectory '${zAppServerWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Invokes script to build the application server control region adjunct proc
echo Building application server control region adjunct proc
'${zAppServerSmpePath}/bin/zCreateProc.sh' \
 -procName '${zAppServerAdjunctProcName}' \
 -procType CRA \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zAppServerConfigMountPoint}' \
 -wasServerDirectory '${zAppServerWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit $rc
fi 

# Invokes script to build the application server servant region proc
echo Building application server servant region proc
'${zAppServerSmpePath}/bin/zCreateProc.sh' \
 -procName '${zAppServerServantProcName}' \
 -procType ASR \
 -targetDirectory "$workDirPath"'/procs' \
 -mountPoint '${zAppServerConfigMountPoint}' \
 -wasServerDirectory '${zAppServerWasServerDir}' \
 -workDirectory "$workDirPath"
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi 

# Copies procs from collection directory to proclib
echo Copying procs from collection directory to proclib
'${zSmpePath}/bin/zCopyFilesToPds.sh' \
 -sourceDirectory "$workDirPath"'/procs' \
 -targetPDS '${zProclibName}'
rc="$?" 
if [ "$rc" -ne 0 ]; then
    exit "$rc"
fi

# Deletes the directory used to collect the customized procs
echo Deleting the directory that was used to collect the customized procs
rm -R -targetDirectory "$workDirPath"'/procs'

echo All procs successfully created
 
exit 0
                                                                              
