Date Created: Sun 05-Dec-2010

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Scripting a Deployment Manager and Node creation


Here are the results of running these two commands using the script below

./install.sh -t node -p true -f /home/was/scripts/node6101.props
./install.sh -t dmgr-p true -f /home/was/scripts/dmgr61.props

Sample output seen during installing a DMGR using the script below

./manageprofiles.sh -create -profileName dmgr61 -profilePath /var/apps/was61/dmgr61/profiles -templatePath /var/apps/was61/dmgr61/profileTemplates/dmgr -cellName cell61 -hostName dmgr61.webspheretools.com -nodeName dmgr61 -startingPort 10000 -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin

Sample output seen during installing a NODE using the script below


./manageprofiles.sh -create -profileName node6101 -profilePath /var/apps/was61/node6101/profiles -templatePath /var/apps/was61/node6101/profileTemplates/managed -cellName node6101 -hostName dmgr61.webspheretools.com -nodeName node6101 -startingPort 11000 -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin -dmgrHost dmgr61.webspheretools.com -dmgrPort 10004 -dmgrAdminUserName wasadmin -dmgrAdminPassword wasadmin


Sample script for installing a deployment manager and node

#!/bin/bash
# Init
FILE="/tmp/out.$$"
GREP="/bin/grep"
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "The script [$0] must be run as root" 1>&2
exit 1
fi

getVars ()
{

export CELL_NAME=`sed '/^\#/d' ${PROPS_FILE} | grep 'CELL_NAME' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export ENV=`sed '/^\#/d' ${PROPS_FILE} | grep 'ENV' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export HOST=`sed '/^\#/d' ${PROPS_FILE} | grep 'HOST' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export DMGR_HOST=`sed '/^\#/d' ${PROPS_FILE} | grep 'DMGR_HOST' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export PROFILE_NAME=`sed '/^\#/d' ${PROPS_FILE} | grep 'PROFILE_NAME' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export NODE_NAME=`sed '/^\#/d' ${PROPS_FILE} | grep 'NODE_NAME' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export START_PORT=`sed '/^\#/d' ${PROPS_FILE} | grep 'START_PORT' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export DMGR_SOAP_PORT=`sed '/^\#/d' ${PROPS_FILE} | grep 'DMGR_SOAP_PORT' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export ROOT_DIR=`sed '/^\#/d' ${PROPS_FILE} | grep 'ROOT_DIR' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export INSTALLER_SRC_DIR=`sed '/^\#/d' ${PROPS_FILE} | grep 'INSTALLER_SRC_DIR' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export INSTALLER_CMD=`sed '/^\#/d' ${PROPS_FILE} | grep 'INSTALLER_CMD' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export INSTALLER_PARAM=`sed '/^\#/d' ${PROPS_FILE} | grep 'INSTALLER_PARAM' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export INSTALLER_LOG=`sed '/^\#/d' ${PROPS_FILE} | grep 'INSTALLER_LOG' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UNINSTALL_CMD=`sed '/^\#/d' ${PROPS_FILE} | grep 'UNINSTALL_CMD' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UNINSTALL_PARAM=`sed '/^\#/d' ${PROPS_FILE} | grep 'UNINSTALL_PARAM' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UNINSTALL_LOG=`sed '/^\#/d' ${PROPS_FILE} | grep 'UNINSTALL_LOG' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export SCRIPT_DIR=`sed '/^\#/d' ${PROPS_FILE} | grep 'SCRIPT_DIR' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UI_INSTALLER_SRC_DIR=`sed '/^\#/d' ${PROPS_FILE} | grep 'UI_INSTALLER_SRC_DIR' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UI_INSTALLER_CMD=`sed '/^\#/d' ${PROPS_FILE} | grep 'UI_INSTALLER_CMD' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export UI_INSTALLER_PARAM=`sed '/^\#/d' ${PROPS_FILE} | grep 'UI_INSTALLER_PARAM' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export FP_INSTALLER_PATH=`sed '/^\#/d' ${PROPS_FILE} | grep 'FP_INSTALLER_PATH' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export FP_INSTALLER_CMD=`sed '/^\#/d' ${PROPS_FILE} | grep 'FP_INSTALLER_CMD' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
export FP_INSTALLER_PARAM=`sed '/^\#/d' ${PROPS_FILE} | grep 'FP_INSTALLER_PARAM' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'`
}
printVars()
{
## Echo all properties found in the props file ##
#WebSphere Specific Vars
echo "CELL_NAME="${CELL_NAME}
echo "ENV="${ENV}
echo "HOST="${HOST}
echo "PROFILE_NAME="${PROFILE_NAME}
echo "NODE_NAME="${NODE_NAME}
echo "START_PORT="${START_PORT}
# Directories for target install
echo "ROOT_DIR="${ROOT_DIR}
# General Installer parameters
echo "INSTALLER_SRC_DIR="${INSTALLER_SRC_DIR}
echo "INSTALLER_CMD="${INSTALLER_CMD}
echo "INSTALLER_PARAM="${INSTALLER_PARAM}
# General Uninstaller parameters
echo "UNINSTALL_CMD="${UNINSTALL_CMD}
echo "UNINSTALL_PARAM="${UNINSTALL_PARAM}
echo "UNINSTALL_LOG="${UNINSTALL_LOG}
echo "UI_INSTALLER_SRC_DIR="${UI_INSTALLER_SRC_DIR}
echo "UI_INSTALLER_CMD="${UNINSTALL_PARAM}
echo "UI_INSTALLER_PARAM="${UI_INSTALLER_CMD}
echo "FP_INSTALLER_PATH="${FP_INSTALLER_PATH}
echo "FP_INSTALLER_CMD="${FP_INSTALLER_CMD}
echo "FP_INSTALLER_PARAM="${FP_INSTALLER_PARAM}
echo "SCRIPT_DIR="${SCRIPT_DIR}
echo "TYPE="${TYPE}
echo "RESPONSE_FILE="${RESPONSE_FILE}

}

queryExisting()
{
#Query existing installations
export VERIFY_ROOT="/installRegistryUtils/bin"
echo ${VERIFY_ROOT}

export VERIFY_ENV_CMD="setInstallRegistryUtilsEnv.sh"
echo ${VERIFY_ENV_CMD}

export VERIFY_CMD="installRegistryUtils.sh -listProducts"
echo ${VERIFY_CMD}

echo "Setting up verify environment vars \"${INSTALLER_SRC_DIR}/$VERIFY_ROOT}/${VERIFY_ENV_CMD}\" from ${PWD}"
${INSTALLER_SRC_DIR}/${VERIFY_ROOT}/${VERIFY_ENV_CMD}

echo "Running CMD \"${INSTALLER_SRC_DIR}/$VERIFY_ROOT}/${VERIFY_CMD}\" from ${PWD}"
${INSTALLER_SRC_DIR}/${VERIFY_ROOT}/${VERIFY_CMD}
}

create_DM_Profile()
{
#Create DMGR Profile
cd ${ROOT_DIR}/${ENV}/bin
echo "Running ${ROOT_DIR}/${ENV}/bin/manageprofiles.sh from ${PWD}"
echo "Running CMD: ./manageprofiles.sh -create -profileName ${PROFILE_NAME} -profilePath ${ROOT_DIR}/${ENV}/profiles -templatePath ${ROOT_DIR}/${ENV}/profileTemplates/dmgr -cellName ${CELL_NAME} -hostName ${HOST} -nodeName ${NODE_NAME} -startingPort ${START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin"
./manageprofiles.sh -create -profileName ${PROFILE_NAME} -profilePath ${ROOT_DIR}/${ENV}/profiles -templatePath ${ROOT_DIR}/${ENV}/profileTemplates/dmgr -cellName ${CELL_NAME} -hostName ${HOST} -nodeName ${NODE_NAME} -startingPort ${START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin
cat ${ROOT_DIR}/${ENV}/profiles/logs/AboutThisProfile.txt
#chown -R was:was ${ROOT_DIR}
}

start_DM()
{
echo "If you are to add nodes, then start the Deployment Manager using ${ROOT_DIR}/${ENV}/bin/startManager.sh"
}

create_Node_Profile()
{
#Create Node Profile
cd ${ROOT_DIR}/${ENV}/bin
echo "Running ${ROOT_DIR}/${ENV}/bin/manageprofiles.sh from ${PWD}"
echo "Running CMD: ./manageprofiles.sh -create -profileName ${PROFILE_NAME} -profilePath ${ROOT_DIR}/${ENV}/profiles -templatePath ${ROOT_DIR}/${ENV}/profileTemplates/managed -cellName ${CELL_NAME} -hostName ${HOST} -nodeName ${NODE_NAME} -startingPort ${START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin -dmgrHost ${DMGR_HOST} -dmgrPort ${DMGR_SOAP_PORT} -dmgrAdminUserName wasadmin -dmgrAdminPassword wasadmin"
./manageprofiles.sh -create -profileName ${PROFILE_NAME} -profilePath ${ROOT_DIR}/${ENV}/profiles -templatePath ${ROOT_DIR}/${ENV}/profileTemplates/managed -cellName ${CELL_NAME} -hostName ${HOST} -nodeName ${NODE_NAME} -startingPort ${START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin -dmgrHost ${DMGR_HOST} -dmgrPort ${DMGR_SOAP_PORT} -dmgrAdminUserName wasadmin -dmgrAdminPassword wasadmin
cat ${ROOT_DIR}/${ENV}/profiles/logs/AboutThisProfile.txt
#chown -R was:was ${ROOT_DIR}
}

start_Node()
{
echo "you can start the node using: ${ROOT_DIR}/${ENV}/bin/startNode.sh"
}

/var/apps/was61/node61_01/bin/manageprofiles.sh -create -profileName node01 -profilePath /var/apps/was61/node61_01/profiles -templatePath /var/apps/was61/node61_01/profileTemplates/managed -cellName node61_01 -hostName node6101.<your_domain.com> -nodeName node61_01

install_Binaries()
{
#Install a Depoyment Manager or node
echo "cd ${INSTALLER_SRC_DIR}"
cd ${INSTALLER_SRC_DIR}
echo "Running silent install using \"${RESPONSE_FILE}\" from ${PWD}"
echo "Running CMD: ${INSTALLER_CMD} -options ${RESPONSE_FILE} ${INSTALLER_PARAM}"
${INSTALLER_CMD} -options ${RESPONSE_FILE} ${INSTALLER_PARAM}
echo "==============="
cd ${ROOT_DIR}/${ENV}/
tail ${INSTALLER_LOG}
echo "==============="

}

uninstall_Binaries()
{
#Todo: Check is already uinstalled
#Todo: Trap ./uninstall/uninstall: No such file or directory

#Uninstall Deployment Manager
cd ${ROOT_DIR}/${ENV}/
echo "Running CMD: ${UNINSTALL_CMD} ${UNINSTALL_PARAM} from ${PWD}"
${UNINSTALL_CMD} ${UNINSTALL_PARAM}
echo "==============="
cd ${ROOT_DIR}/${ENV}/
tail ${UNINSTALL_LOG}
echo "==============="
echo "Delete the folder ${ROOT_DIR}/${ENV} before you try an install into the same folder!"

}

InstallUpdateInstaller()
{
#Installs the latest update installer

echo "cd ${UI_INSTALLER_SRC_DIR}"
cd ${UI_INSTALLER_SRC_DIR}
echo "Running silent install using \"${RESPONSE_FILE}\" from ${PWD}"
echo "Running CMD: ${UI_INSTALLER_CMD} -options ${RESPONSE_FILE} ${UI_INSTALLER_PARAM}"
${UI_INSTALLER_CMD} -options ${RESPONSE_FILE} ${UI_INSTALLER_PARAM}
}


InstallFixPack()
{
#Installs the latest fixpack

echo "cd ${FP_INSTALLER_PATH}"
cd ${FP_INSTALLER_PATH}
echo "Running silent install using \"${RESPONSE_FILE}\" from ${PWD}"
echo "Running CMD: ${FP_INSTALLER_CMD} -options ${RESPONSE_FILE} ${FP_INSTALLER_PARAM}"
${FP_INSTALLER_CMD} -options ${RESPONSE_FILE} ${FP_INSTALLER_PARAM}
}

#############
#### MAIN ###
#############

#Get command live variables
while getopts "t:f:u:r:g:p:" flag
do
echo "$flag" $OPTIND $OPTARG
case $flag in
t) export TYPE="${OPTARG}";;
f) export PROPS_FILE="${OPTARG}";;
r) export RESPONSE_FILE="${OPTARG}";;
g) export UPGRADE="${OPTARG}";;
u) export UNINSTALL="${OPTARG}";;
p) export ADD_PROFILE="${OPTARG}";;
esac
done

if [ "<"${TYPE}">" = "<>" ]; then
echo "An install type must be selected!"
exit 1
fi


if [ "<"${PROPS_FILE}">" = "<>" ]; then
echo "A props file containing environment settings must exist!"
exit 1
fi

if [ "<"${ADD_PROFILE}">" != "<true>" ]; then
if [ "<"${RESPONSE_FILE}">" = "<>" ]; then
echo "A response file must exist!"
exit 1
fi
fi

#Source the properties from the props file:
getVars
printVars

if [ "<"${UNINSTALL}">" = "<true>" ]; then
uninstall_Binaries
exit 0
fi

if [ "<"${TYPE}">" = "<dmgr>" ]; then

if [ "<"${ADD_PROFILE}">" = "<true>" ]; then
echo "creating a Deployment Manager profile"
create_DM_Profile
start_DM
exit 0
fi

if [ "<"${UPGRADE}">" = "<true>" ]; then
echo "installing the update installer"
#InstallUpdateInstaller
InstallFixPack
else
echo "A Depoyment Manager install has been chosen"
install_Binaries
fi



#queryExisting

else

if [ "<"${ADD_PROFILE}">" = "<true>" ]; then
echo "creating a node profile"
create_Node_Profile
start_Node
exit 0
fi

if [ "<"${UPGRADE}">" = "<true>" ]; then
echo "installing the update installer"
#InstallUpdateInstaller
InstallFixPack
else
echo "A Node install has been chosen"
install_Binaries
fi

#queryExisting
#create_Node_Profile
fi

exit 0

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


  • Linked In
  • Twitter
  • About Me
  • My Blog
  • Contact Me

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories