websphere 命令行添加profile

参考链接:
[url]http://hjs0512.iteye.com/blog/975356[/url]

websphere linux 中添加新的profile 指定管理员和新的profile相关端口。websphere版本为7.0。
1,命令如下:

/opt/IBM/WebSphere/AppServer/bin/manageprofiles.sh -create -profileName ilog -profilePath /opt/IBM/WebSphere/AppServer/profiles/ilog -templatePath /opt/IBM/WebSphere/AppServer/profileTemplates/default -nodeName DefaultNode -hostName localhost -cellName DefaultNode -isDefault -portsFile /opt/ilog.props -enableAdminSecurity true -adminUserName admin -adminPassword admin

2,profile端口ilog.props文件内容如下:

WC_defaulthost=12100
WC_adminhost=12104
WC_defaulthost_secure=12101
WC_adminhost_secure=12105
BOOTSTRAP_ADDRESS=12102
SOAP_CONNECTOR_ADDRESS=12103
SAS_SSL_SERVERAUTH_LISTENER_ADDRESS=9405
CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS=9406
CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS=9407
ORB_LISTENER_ADDRESS=9105
DCS_UNICAST_ADDRESS=9375
IPC_CONNECTOR_ADDRESS=5563
SIB_ENDPOINT_ADDRESS=7276
SIB_ENDPOINT_SECURE_ADDRESS=7286
SIB_MQ_ENDPOINT_ADDRESS=5558
SIB_MQ_ENDPOINT_SECURE_ADDRESS=5577
SIP_DEFAULTHOST=5075
SIP_DEFAULTHOST_SECURE=5076

3,新的profile的管理员连接

http://localhost:12104/admin


admin


admin


http://localhost:12100/appName

4,删除profile

/opt/IBM/WebSphere/AppServer/bin/manageprofiles.sh -delete -profileName ilog


参考代码:
IBM Tivoli linux版 idstools下的deploy_IDSWebApp shell
shell功能:将TDS部署在WAS新的profile中。
shell代码放在附件中传不上来。
索性直接贴出来得了。

#!/bin/sh
#DEBUG=TRUE

################################################################################
#
# Header
#
# Licensed Materials - Property of IBM Corp.
# (C) Copyright IBM Corp. 2004
#
# All Rights Reserved
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

SCRIPT_VER=01.15
SCRIPT_DATE=01/18/2010
SCRIPT_SCCS=

################################################################################
#
# History
#
# DATE Ver Auth Abstract
# ---------- ----- ----------- ----------------------------------
# 11/15/2004 00.01 brookh initial design
# 11/18/204 01.00 brookh add "-v" option
# 11/26/2004 01.01 brookh Check server status before stop/start
# 11/26/2004 01.02 brookh .pid file is not reliable immediately after
# start/stop, so only check before first start
# 06/22/2005 01.03 dukepham Add copying IDSWebApp.war to installableApps/SHOMEPath
# and change the way this script to be executed
# at <LDAPHome>/idstools/
# 05/15/2006 01.05 Amit Kumar Support for -h, -f, -a, -e and -r options
# in the deployment script
# 05/25/2006 01.06 Aalhad Saraf Remove redundant options. Integrate SunOS code.
# 06/30/2006 01.07 Amit Kumar script should run from idstools folder
# 07/10/2006 01.08 Amit Kumar deploy_IDSWebApp needs minor updates
# 07/18/2006 01.09 Amit Kumar deploy_IDSWebApp -v option does not show full info
# 07/27/2009 01.10 Ripen Added -portsFile option to wasprofile command,
# modified copying IDSWebApp.war to
# %WAS_HOME%\profiles\<PROFILE_NAME>\installableApps\
# 10/03/2006 01.11 Ripen Added support for translated messages
# 02/23/2007 01.13 Pradnya Pol Added support for -o option (ports def file)
# 04/02/2007 01.14 Ripen Added support for jacl script(required for webadmin logs)
# 03/19/2008 D101143 Ripen Removed extra messages
# 08/26/2008 D100650 Ripen Incorrect location for WAR file version
# 01/08/2010 D109155 fchang 61 deploy_IDSWebApp doesn't work when called with absolute path
# 01/19/2010 D109251 fchang deploy_IDSWebApp reports invalid war file

################################################################################
################################################################################
#
#Usage: ./deploy_IDSWebApp.sh [-v] [-h] [-w IDSWebApp.war file]
# [-a Application Name [-u]]
# [-p location of app server] [-r profile]
# [-o ports file]
#
# Deploys IDSWebApp.war to WAS, retaining the configuration settings of the
# currently deployed IDSWebApp, if any.
#
#NOTE: deploy_IDSWebApp.sh must be present in /TDS installpath/idstools folder.
#
#
#{-h Display Usage. }
#
#{-v Display the version and date strings for the deploy_IDSWebApp
# script and the application war file.}
#
#{-a Application Name. Defaults to IDSWebApp.war if not specified. }
#
#{-u Uninstall a previously existing application.
# -a option should be used to specify the application to uninstall
# If not specified default application IDSWebApp.war will be
# un-deployed.}
#
# The following options are necessary for all operations associated with
# non-embedded WAS deployments and optionally may also be used for embedded
# WAS.
#
#{-w The fully qualified path of the IDSWebApp.war file to deploy. }
#
#{-p Location of WebSphere Application Server where the application is
# to be deployed. }
#
#{-r Profile name associated with the application. Default assumed if not
# specified is - 'TDSWebAdminProfile'. }
#{-o Fully qualified path of the ports definition file. Default assumed if not
# specified is 'TDS Install directory/idstools/TDSWEBPortDef.props'. }
#
#
################################################################################
################################################################################


DEBUG_FLAG="FALSE"
MAIN_PLATFORM=`eval 'uname'`
IDSWebAppWarFileName="IDSWebApp.war"
EXETIMESTAMP=`date +"%m-%d-%y_%H-%M-%S"`
DefaultWASHOMEPath=`eval 'dirname $0'`/../appsrv/
DefaultidstoolsPath=`eval 'dirname $0'`/../idstools/
DefaultMSGPath=`eval 'dirname $0'`/../nls/msg
WAS_SERVER=server1
WASHOMEPath=
PATCH_SCRIPT=
WAS_TEMP=
APP_ROOT=
IDSWebApp_Name=
IDSToolsPath=
IDSWebApp=
NEW_IDSWebApp=
OPTION_V=FALSE
OPTION_H=FALSE
IDSWebAppInfo=WEB-INF/classes/IDSConfig/IDSWebAppInfo/IDSWebAppInfo.xml
CONFIG_FILES="\
WEB-INF/classes/security/console_passwd \
WEB-INF/classes/IDSConfig/IDSServersConfig/IDSServersInfo.xml \
WEB-INF/classes/IDSConfig/IDSAppReg/IDSAppReg.xml \
WEB-INF/classes/IDSConfig/IDSSessionConfig/IDSSessionMgmt.xml \
"
NewIDSWebAppWarVer=
DeployedIDSWebAppWarVer=
QualifiedPath=
WAS_NODE=DefaultNode
UNINSTALL_TEMP="${WAS_HOME}/temp/uninstall_IDSWebApp.tmp"
PRE60_SERV=FALSE
UNINSTALL_ONLY=FALSE
WASPORTSPath=
WASPortsFileName=TDSWEBPortDef.props

################################################################################
#
# Set QualifiedPath of $1, or return error and clear QualifiedPath
#
QualifyPath()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ $1 ]; then
QualifiedPath=
save_PWD=`pwd`
cd `dirname ${1}` || return $?
QualifiedPath=`pwd`/`basename ${1}`
cd ${save_PWD}
else ## $1 is null
QualifiedPath=`pwd`
fi
}

################################################################################
#
# Delete ${WAS_HOME}/temp/uninstall_IDSWebApp.tmp directory
# Used during uninstall_only
#
uninstall_DeleteTempDirectory()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi
if [ -d ${UNINSTALL_TEMP} ]; then
rm -rf ${UNINSTALL_TEMP}
fi
}


################################################################################
#
# Create empty ${WAS_HOME}/temp/uninstall_IDSWebApp.tmp directory
# Used during uninstall_only
#
uninstall_CreateTempDirectory()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi
uninstall_DeleteTempDirectory || return $?
mkdir -p ${UNINSTALL_TEMP} || return $?
}

################################################################################
#
# Backup CONFIG_FILES (if any) from APP_ROOT to UNINSTALL_TEMP
# Used during uninstall_only
#
uninstall_Backup_IDSWebApp_Configuration()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

#Set up the environment variables
if [ -d ${APP_ROOT} ]; then
:
else
return 0
fi
for filename in ${CONFIG_FILES}; do
if [ -f ${APP_ROOT}/${filename} ]; then
EchoCmd mkdir -p ${UNINSTALL_TEMP}/`dirname ${filename}` || return 1
EchoCmd cp ${APP_ROOT}/${filename} ${UNINSTALL_TEMP}/${filename} || return 1
fi
done

return 0
}

################################################################################
# This function is used to only uninstall the already installed IDSWebApp.war
# application
#

uninstall_only () {

echo ""
if [ ${TRANSLATE_MSG} = TRUE ]; then
cd ../bin
./tbindmsg ldapsh 1 40 "\nYou have chosen to UNDEPLOY %1\\\$s\n\nThe configuration files for the current application will be stored in %2\\\$s\n\n" "${IDSWebApp_Name}" "${WAS_HOME}/temp/uninstall_IDSWebApp.tmp"
else
echo "You have chosen to undeploy ${IDSWebApp_Name}"
echo ""
echo "The configuration files for the current application will be stored in ${WAS_HOME}/temp/uninstall_IDSWebApp.tmp"
fi

if [ -z "${IDSWebApp_Name}" ]; then
IDSWebApp_Name="IDSWebApp.war"
fi

if [ ${TRANSLATE_MSG} = TRUE ]; then
cd ../bin
./tbindmsg ldapsh 1 41 "\nAn application named %1\\\$s will be undeployed\n\n" "${IDSWebApp_Name}"
else
echo "The application ${IDSWebApp_Name} will be undeployed"
fi

uninstall_CreateTempDirectory || return $?
uninstall_Backup_IDSWebApp_Configuration || return $?

if [ ${PRE60_SERV} = FALSE ]; then
if [ ! -f ${WAS_HOME}/profiles/${PROFILE_NAME}/logs/${WAS_SERVER}/${WAS_SERVER}.pid ]; then
Start_WAS || return $?
fi
else
if [ ! -f ${WAS_HOME}/logs/${WAS_SERVER}/${WAS_SERVER}.pid ]; then
Start_WAS || return $?
fi
fi

Uninstall_IDSWebApp
exit 0;

}

################################################################################
# This function is used to print the help for deploy_IDSWebApp.sh
#


printusage () {

if [ ${TRANSLATE_MSG} = TRUE ]; then
cd ../bin
./tbindmsg ldapsh 1 39 "\n Usage: deploy_IDSWebApp [-v] [-h] [-w war_file_path]\n [-a app_name [-u]] \n [-p app_server_path] [-r profile_name]\n [-o ports_file]\n\n Deploys IDSWebApp.war file to WebSphere Application Server, retaining the configuration\n settings of the currently deployed IDSWebApp, if any.\n\n Note: deploy_IDSWebApp must be present in the /TDS installpath/idstools folder.\n\n -a app_name Application name, defaults to IDSWebApp.war if not specified.\n -h Display the usage. \n -u Uninstall a previously existing application.\n Option -a should be used to specify the application to uninstall.\n If not specified, the default application IDSWebApp.war will be undeployed.\n -v Display the version and date strings for the deploy_IDSWebApp\n command and the application war file.\n\n The following options are necessary for all operations associated with\n non Embedded WAS deployments and optionally can also be used for Embedded WAS.\n\n -p app_server_path Location of WebSphere Application Server where the application is\n to be deployed.\n -r profile_name Profile name associated with the application.\n If not specified, the default is 'TDSWebAdminProfile'.\n -w war_path_path The fully qualified path of the IDSWebApp.war file to deploy.\n -o ports_file The fully qualified path of the ports definition file to use.\n If not specified, the default is 'TDS Install directory/idstools/TDSWEBPortDef.props'.\n"
else
echo "Usage: ./deploy_IDSWebApp [-v] [-h] [-w IDSWebApp.war file]
[-a Application Name [-u]]
[-p location of app server] [-r profile]
[-o ports file]
Deploys IDSWebApp.war to WAS, retaining the configuration settings of the
currently deployed IDSWebApp, if any.

NOTE: deploy_IDSWebApp must be present in /TDS installpath/idstools/ folder.


{-h Display Usage. }

{-v Display the version and date strings for the deploy_IDSWebApp
script and the application war file.}

{-a Application Name. Defaults to IDSWebApp.war if not specified. }

{-u Uninstall a previously existing application.
-a option should be used to specify the application to uninstall
If not specified default application IDSWebApp.war will be un-deployed.}

The following options are necessary for all operations associated with
non-embedded WAS deployments and optionally may also be used for embedded WAS.

{-w The fully qualified path of the IDSWebApp.war file to deploy. }

{-p Location of WebSphere Application Server where the application is
to be deployed. }

{-r Profile name associated with the application. Default assumed if not
specified is - 'TDSWebAdminProfile'. }

{-o Fully qualified path of the ports definition file. Default assumed if not
specified is 'TDS Install directory/idstools/TDSWEBPortDef.props'. }
"
fi
exit 0

}

################################################################################
#
# Print localized "File not found" error and return failure RC
#
AssertFileExists()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ ! -f $1 ]; then
ls $1 >/dev/null
fi
}

################################################################################
#
# Echo cmd and then call it
#
EchoCmd()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

echo ""
echo "$*"
eval "$*"
}


################################################################################
#
# Initialize all needed variables
InitGlobalVariables()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

QualifyPath $1 || return $?
IDSToolsPath=`dirname ${QualifiedPath}`
PATCH_SCRIPT=${QualifiedPath}

if [ ${WASHOMEPath} ]; then
:
else
QualifyPath ${DefaultWASHOMEPath} || return $?
WASHOMEPath=${QualifiedPath}
fi


if [ -z "${IDSWebApp_Name}" ]; then
IDSWebApp_Name="IDSWebApp.war"
fi

## Execution of setupCmdLine.sh will set all needed environment variables
## such as: ${WAS_HOME} and ${JAVA_HOME} etc.
cd "${WASHOMEPath}/bin/"

AssertFileExists "${WASHOMEPath}/bin/setupCmdLine.sh" || return $?
. "${WASHOMEPath}/bin/setupCmdLine.sh" || return $?

if [ ! -f ${WAS_HOME}/bin/wasprofile.sh ]; then
if [ -f ${WASHOMEPath}/bin/wasprofile.sh ]; then
WAS_HOME=${WASHOMEPath}
fi
fi

cd ${IDSToolsPath}

AssertFileExists "${WASHOMEPath}/bin/wsadmin.sh" || return $?

UNINSTALL_TEMP="${WAS_HOME}/temp/uninstall_IDSWebApp.tmp"

if [ ! -f "${WASHOMEPath}/bin/wasprofile.sh" ]; then
PRE60_SERV=TRUE
fi

WAS_TEMP="${WAS_HOME}/temp/deploy_IDSWebApp.tmp"

APP_ROOT="${WAS_HOME}/installedApps/${WAS_NODE}/${IDSWebApp_Name}.ear/IDSWebApp.war"

if [ ${PROFILE_NAME} ]; then
:
else
PROFILE_NAME=TDSWebAdminProfile
fi

if [ ${PRE60_SERV} = FALSE ]; then
APP_ROOT=${WAS_HOME}/profiles/${PROFILE_NAME}/installedApps/DefaultNode/${IDSWebApp_Name}.ear/IDSWebApp.war
fi

if [ ${IDSWebApp} ]; then
NEW_IDSWebApp=${IDSWebApp}
else
if [ "${MAIN_PLATFORM}" = "AIX" ]; then
AssertFileExists ${IDSToolsPath}/${IDSWebAppWarFileName?}
if [ $? -eq 0 ]; then
QualifyPath ${IDSToolsPath}/${IDSWebAppWarFileName?}
else
AssertFileExists ${IDSToolsPath}/nossl/${IDSWebAppWarFileName?} || return $?
QualifyPath ${IDSToolsPath}/nossl/${IDSWebAppWarFileName?}
fi
else
AssertFileExists ${IDSToolsPath}/${IDSWebAppWarFileName?} || return $?
QualifyPath ${IDSToolsPath}/${IDSWebAppWarFileName?}
fi
NEW_IDSWebApp=${QualifiedPath}
fi

if [ ${WASPORTSPath} ]; then
:
else
if [ "${MAIN_PLATFORM}" = "AIX" ]; then
AssertFileExists ${IDSToolsPath}/${WASPortsFileName?}
if [ $? -eq 0 ]; then
QualifyPath ${IDSToolsPath}/${WASPortsFileName?}
else
AssertFileExists ${IDSToolsPath}/nossl/${WASPortsFileName?} || return $?
QualifyPath ${IDSToolsPath}/nossl/${WASPortsFileName?}
fi
else
AssertFileExists ${IDSToolsPath}/${WASPortsFileName?} || return $?
QualifyPath ${IDSToolsPath}/${WASPortsFileName?}
fi
WASPORTSPath=${QualifiedPath}
fi

}

################################################################################
#
# Delete ${WAS_HOME}/temp/IDSWebApp.tmp directory
#
DeleteTempDirectory()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -d ${WAS_TEMP} ]; then
rm -rf ${WAS_TEMP}
fi
}

################################################################################
#
# Create empty ${WAS_HOME}/temp/IDSWebApp.tmp directory
#
CreateTempDirectory()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

DeleteTempDirectory || return $?
mkdir -p ${WAS_TEMP} || return $?
}

################################################################################
#
# Backup CONFIG_FILES (if any) from APP_ROOT to WAS_TEMP
#
Backup_IDSWebApp_Configuration()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

## Set up the environment variables

if [ ! -d ${APP_ROOT} ]; then
return 0
fi

for filename in ${CONFIG_FILES}; do
if [ -f ${APP_ROOT}/${filename} ]; then
EchoCmd mkdir -p ${WAS_TEMP}/`dirname ${filename}` || return 1
EchoCmd cp ${APP_ROOT}/${filename} ${WAS_TEMP}/${filename} || return 1
fi
done

return 0
}

################################################################################
#
# Restore CONFIG_FILES (if any) from WAS_TEMP to APP_ROOT
#
Restore_IDSWebApp_Configuration()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

for filename in ${CONFIG_FILES}; do
if [ -f ${WAS_TEMP}/${filename} ]; then
EchoCmd cp ${WAS_TEMP}/${filename} ${APP_ROOT}/${filename} || return 1
fi
done

return 0
}


################################################################################
#
# Start WAS server1
#
Start_WAS()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ ${PRE60_SERV} = FALSE ]; then
EchoCmd "${WAS_HOME}/profiles/${PROFILE_NAME}/bin/startServer.sh" ${WAS_SERVER} || return $?
else
EchoCmd "${WAS_HOME}/bin/startServer.sh" ${WAS_SERVER} || return $?
fi
}

################################################################################
#
# Stop WAS server1
#
Stop_WAS()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi
if [ ${PRE60_SERV} = FALSE ]; then
EchoCmd "${WAS_HOME}/profiles/${PROFILE_NAME}/bin/stopServer.sh" ${WAS_SERVER} || return $?
else
EchoCmd "${WAS_HOME}/bin/stopServer.sh" ${WAS_SERVER} || return $?
fi
}

################################################################################
#
# Restart WAS server1
#
Restart_WAS()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

Stop_WAS
Start_WAS || return $?
}

################################################################################
#
# Un-deploy existing IDSWebApp.war (if found)...
#
Uninstall_IDSWebApp()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -d ${APP_ROOT} ]; then
if [ ${PRE60_SERV} = FALSE ]; then
EchoCmd ${WAS_HOME}/bin/wsadmin.sh '-conntype NONE -profileName ${PROFILE_NAME} -c "\$AdminApp uninstall ${IDSWebApp_Name}"' || return $?
else
EchoCmd ${WAS_HOME}/bin/wsadmin.sh '-conntype NONE -c "\$AdminApp uninstall ${IDSWebApp_Name}"' || return $?
fi
fi
return 0
}

################################################################################
#
# Deploy new IDSWebApp.war...
#
Install_IDSWebApp()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ ${PRE60_SERV} = FALSE ]; then
cd "${WASHOMEPath}/bin/"

if [ ! -d ${WAS_HOME}/profiles/${PROFILE_NAME} ]; then
if [ -f ${WAS_HOME}/bin/manageprofiles.sh ]; then
EchoCmd ${WAS_HOME}/bin/manageprofiles.sh "-create -profileName ${PROFILE_NAME} -profilePath "${WAS_HOME}/profiles/${PROFILE_NAME}" -templatePath "${WAS_HOME}/profileTemplates/default" -nodeName DefaultNode -hostName localhost -cellName DefaultNode -isDefault -portsFile "${WASPORTSPath}""
else
EchoCmd ${WAS_HOME}/bin/wasprofile.sh "-create -profileName ${PROFILE_NAME} -profilePath "${WAS_HOME}/profiles/${PROFILE_NAME}" -templatePath "${WAS_HOME}/profileTemplates/default" -nodeName DefaultNode -hostName localhost -cellName DefaultNode -isDefault -portsFile "${WASPORTSPath}""
fi
fi

EchoCmd ${WAS_HOME}/profiles/${PROFILE_NAME}/bin/wsadmin.sh '-conntype NONE -c "\$AdminApp install {'${NEW_IDSWebApp}'} {-configroot \"${WAS_HOME}/config\" -node DefaultNode -usedefaultbindings -nodeployejb -appname ${IDSWebApp_Name} -contextroot \"IDSWebApp\"}"'

cd ${IDSToolsPath}
else
EchoCmd ${WAS_HOME}/bin/wsadmin.sh '-conntype NONE -c "\$AdminApp install {'${NEW_IDSWebApp}'} {-configroot \"$CONFIG_ROOT\" -node \"$WAS_NODE\" -usedefaultbindings -nodeployejb -appname ${IDSWebApp_Name} -contextroot \"IDSWebApp\"}"'
fi

return $?
}

################################################################################
#
# Display app-version and build-date of IDSWebAppInfo.xml file
# or localized 'not found' message
#
ShowIDSWebAppInfo()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -f $1 ]; then
egrep '(app-version|build-date)' $1
else
ls $1 >/dev/null
fi
}

################################################################################
#
# get the major version of the new war file to:
# ${NewIDSWebAppWarMajorVer}
#
GetVersionInfo_NewIDSWebApp()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -f ${1} ]; then
save_PWD=`pwd`
cd ${WAS_TEMP}
${JAVA_HOME}/bin/jar -xf ${1} ${IDSWebAppInfo}
cd ${save_PWD}
else
return 1
fi

## Get the major version of the new war file
#AssertFileExists ${WAS_TEMP}/${IDSWebAppInfo} || return $?
temp_ver1=`egrep '(app-version)' ${WAS_TEMP}/${IDSWebAppInfo}`
temp_ver2=`echo ${temp_ver1} | awk -F\> '{print $2}'`
temp_ver3=`echo ${temp_ver2} | awk -F\< '{print $1}'`
NewIDSWebAppWarMajorVer=`echo ${temp_ver3} | awk -F\. '{print $1}'`
}

################################################################################
#
# get the major version of deployed war in WAS:
# ${DeployedIDSWebAppWarVer}
#
GetVersionInfo_DeployedIDSWebApp()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -f ${1} ]; then
temp_ver1=`egrep '(app-version)' ${1}`
temp_ver2=`echo ${temp_ver1} | awk -F\> '{print $2}'`
temp_ver3=`echo ${temp_ver2} | awk -F\< '{print $1}'`
DeployedIDSWebAppWarVer=`echo ${temp_ver3} | awk -F\. '{print $1}'`
else
return 0
fi
}

################################################################################
#
# "-v"
# ShowVersionInfo() is made to act as a standalone entity.It would
# initialize its own varibles needed to determine the version and
# exit.
#
ShowVersionInfo()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

## Show script version
echo ""
echo "${PATCH_SCRIPT}:"

if [ ${TRANSLATE_MSG} = TRUE ]; then
cd ../bin
./tbindmsg ldapsh 1 43 "Command Version: %1\\\$s\n Command Date: %2\\\$s\n" "${SCRIPT_VER}" "${SCRIPT_DATE}"
else
echo " Script Version: ${SCRIPT_VER}"
echo " Script Date: ${SCRIPT_DATE}"
fi

QualifyPath $1 || return $?
IDSToolsPath=`dirname ${QualifiedPath}`
PATCH_SCRIPT=${QualifiedPath}

if [ ${WASHOMEPath} ]; then
:
else
QualifyPath ${DefaultWASHOMEPath} || return $?
WASHOMEPath=${QualifiedPath}
fi

if [ -z "${IDSWebApp_Name}" ]; then
IDSWebApp_Name="IDSWebApp.war"
fi

## Execution of setupCmdLine.sh will set all needed environment variables
## such as: ${WAS_HOME} and ${JAVA_HOME} etc.

AssertFileExists "${WASHOMEPath}/bin/setupCmdLine.sh" || return $?
. "${WASHOMEPath}/bin/setupCmdLine.sh" || return $?

## Show version of new IDSWebApp
## echo ""
## echo "${NEW_IDSWebApp}:"

if [ ! -f "${WASHOMEPath}/bin/wasprofile.sh" ]; then
PRE60_SERV=TRUE
fi

if [ ! -f ${WAS_HOME}/bin/wasprofile.sh ]; then
if [ -f ${WASHOMEPath}/bin/wasprofile.sh ]; then
WAS_HOME=${WASHOMEPath}
fi
fi

APP_ROOT="${WAS_HOME}/installedApps/${WAS_NODE}/${IDSWebApp_Name}.ear/IDSWebApp.war"

if [ ${PRE60_SERV} = FALSE ]; then
APP_ROOT=${WASHOMEPath}/profiles/${PROFILE_NAME}/installedApps/DefaultNode/${IDSWebApp_Name}.ear/IDSWebApp.war
fi


echo ""
echo "${APP_ROOT}:"

# D109251

if [ ! -f "${APP_ROOT}/${IDSWebAppInfo}" ]; then
if [ ! -f "${WAS_TEMP}/${IDSWebAppInfo}" ]; then
APP_TEMP=${WASHOMEPath}/../temp/deploy_IDSWebApp.tmp
if [ ! -f "${APP_TEMP}/${IDSWebAppInfo}" ]; then
if [ ${TRANSLATE_MSG} = TRUE ]; then
cd ../bin
./tbindmsg ldapsh 1 37 "Not a valid IDSWebApp.war file.\n"
else
echo "Not a valid IDSWebApp.war file. "
fi
else
ShowIDSWebAppInfo ${APP_TEMP}/${IDSWebAppInfo}
fi
else
ShowIDSWebAppInfo "${WAS_TEMP}/${IDSWebAppInfo}"
fi
else
ShowIDSWebAppInfo ${APP_ROOT}/${IDSWebAppInfo}
fi

echo ""
exit 0
}

################################################################################
#
# Copy the new war to the <WAS install path>/installableApps/ after
# sucessfully deployed the war file.
#
Copy_NewIDSWebApp_To_InstallableApps()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ ${PRE60_SERV} = FALSE ]; then
## rem Check if target exist before copying over.
if [ -f ${WAS_HOME}/profiles/${PROFILE_NAME}/installableApps/IDSWebApp.war ]; then
if [ $? -eq 0 ]; then
## Backup target file before copying if it exists
mv ${WAS_HOME}/profiles/${PROFILE_NAME}/installableApps/IDSWebApp.war \
${WAS_HOME}/profiles/${PROFILE_NAME}/installableApps/IDSWebApp.war_bkup_${EXETIMESTAMP} || return $?
fi
fi
## Copy to override target
cp -Rp ${NEW_IDSWebApp} ${WAS_HOME}/profiles/${PROFILE_NAME}/installableApps/ || return $?

else
AssertFileExists ${WAS_HOME}/installableApps/IDSWebApp.war

if [ $? -eq 0 ]; then
## Backup target file before copying if it exists
mv ${WAS_HOME}/installableApps/IDSWebApp.war \
${WAS_HOME}/installableApps/IDSWebApp.war_bkup_${EXETIMESTAMP} || return $?
fi

## Copy to override target
cp -Rp ${NEW_IDSWebApp} ${WAS_HOME}/installableApps/ || return $?
fi
}

################################################################################
#
# Only allow to deploy war file with exact name: "IDSWebApp.war"
#
Verify_IDSWebApp_Filename()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

## Only set -x when about to quit
[ "${1?}" != "${IDSWebAppWarFileName?}" ] && set -x
[ "${1?}" != "${IDSWebAppWarFileName?}" ] && return 1
return 0
}

################################################################################
#
# Verify war file version and only allow equal of newer version to be
# deployed into already deployed WAS installation.
#
Verify_IDSWebApp_Version()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

## Check the war file version, and DO NOT allow back level war file
## to be deployed to a newer version of deployed WAS.
if [ ${DeployedIDSWebAppWarVer} ]; then
[ ${NewIDSWebAppWarMajorVer} -lt ${DeployedIDSWebAppWarVer} ] && set -x
if [ ${NewIDSWebAppWarMajorVer} -lt ${DeployedIDSWebAppWarVer} ]; then
## Show version of new IDSWebApp
echo ""
echo "${NEW_IDSWebApp}:"
ShowIDSWebAppInfo ${WAS_TEMP}/${IDSWebAppInfo}
## Show version of deployed IDSWebApp
echo ""
echo "${APP_ROOT}/${IDSWebAppInfo}:"
ShowIDSWebAppInfo ${APP_ROOT}/${IDSWebAppInfo}
return 1
fi
fi

return 0
}

################################################################################
#
# main
#
main()
{
if [ ${DEBUG_FLAG} = TRUE ]; then
set -x
fi

if [ -d ${DefaultMSGPath} ]; then
TRANSLATE_MSG=TRUE
fi

if [ ${OPTION_H} = TRUE ]; then
printusage
fi

InitGlobalVariables $1 || return $?

if [ ${OPTION_V} = TRUE ]; then
ShowVersionInfo
fi

CreateTempDirectory || return $?

GetVersionInfo_NewIDSWebApp ${NEW_IDSWebApp} || return $?
GetVersionInfo_DeployedIDSWebApp ${APP_ROOT}/${IDSWebAppInfo}

if [ ${UNINSTALL_ONLY} = TRUE ];then
uninstall_only
exit 0;
fi

if [ ${OPTION_V} = FALSE ]; then
Verify_IDSWebApp_Version || return $?

if [ ${PRE60_SERV} = FALSE ]; then
if [ -f ${WAS_HOME}/profiles/${PROFILE_NAME}/logs/${WAS_SERVER}/${WAS_SERVER}.pid ]; then
Stop_WAS
if [ $? -ne 0 ]; then
Start_WAS || return $?
Stop_WAS || return $?
fi
fi
else
if [ -f ${WAS_HOME}/logs/${WAS_SERVER}/${WAS_SERVER}.pid ]; then
Stop_WAS
if [ $? -ne 0 ]; then
Start_WAS || return $?
Stop_WAS || return $?
fi
fi
fi

Backup_IDSWebApp_Configuration || return $?
Uninstall_IDSWebApp || return $?
Install_IDSWebApp || return $?
Restore_IDSWebApp_Configuration || return $?

Restart_WAS || return $?

# set the logging jar to classpath
"${WAS_HOME}/profiles/${PROFILE_NAME}/bin/wsadmin.sh" -lang jacl -f "${DefaultidstoolsPath}/setLogging.jacl" ${WAS_HOME} ${PROFILE_NAME} DefaultNode ${IDSWebApp_Name}

Restart_WAS || return $?

Copy_NewIDSWebApp_To_InstallableApps || return $?

if [ ${PRE60_SERV} = FALSE ]; then
APP_ROOT=${WAS_HOME}/profiles/${PROFILE_NAME}/installedApps/DefaultNode/${IDSWebApp_Name}.ear/IDSWebApp.war
fi

DeleteTempDirectory
echo ""
if [ ${PRE60_SERV} = TRUE ]; then
echo "${APP_ROOT}:"
ShowIDSWebAppInfo ${APP_ROOT}/${IDSWebAppInfo}
fi
fi
}

################################################################################
###################### MAIN PROGRAM #########################
################################################################################

if [ ${DEBUG} ]; then
DEBUG_FLAG=${DEBUG}
fi

while getopts ":vw:p:a:r:uh" opt
do
case $opt in
v )
OPTION_V=TRUE
;;
w )
AssertFileExists $OPTARG || exit $?
QualifyPath $OPTARG || exit $?
IDSWebApp=${QualifiedPath}
;;
p )
QualifyPath $OPTARG || exit $?
WASHOMEPath=${QualifiedPath}
;;
a )
IDSWebApp_Name=$OPTARG
;;
u )
UNINSTALL_ONLY=TRUE
;;
r )
PROFILE_NAME=$OPTARG
;;
h )
OPTION_H=TRUE
;;
o )
QualifyPath $OPTARG || exit $?
WASPORTSPath=${QualifiedPath}
;;
\? )
OPTION_H=TRUE
;;
* )
exit $?
;;
esac
done

main $0


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值