addNodeToDCCluster

 

#!/bin/bash

### addNodeToDCCluster.sh

### Set script env
binDir=$(dirname ${0})
 . ${binDir}/setupCmdLine.sh

TARGET_NODE_NAME="RulesNode01"
DMGR_ADMIN_USER=
DMGR_ADMIN_PASSWORD=
PROPS_FILE_PATH=

DMGR_HOSTNAME=
DMGR_SOAP_PORT="8879"

function usage() {
    echo "Usage:"
    echo "   ${0} -dmgrAdminUsername username -dmgrAdminPassword password -clusterPropertiesFile filepath [-targetNodeName nodeName] [-createNode] [-unInstall] [-dmgrHostName hostname] [-dmgrPort port]"
    echo "      Mandatory parameters:"
    echo "         -dmgrAdminUsername: the websphere administrator userid"
    echo "         -dmgrAdminPassword: the websphere administrator password"
    echo "         -clusterPropertiesFile: the properties file path"
    echo ""
    echo "      Optional parameters:"
    echo "         -targetNodeName: the target installation node name by default is set to RulesNode01"
    echo "         -dmgrHostName: this parameter is mandatory if we have to create the target node"
    echo "         -dmgrPort: the deployment manager SOAP TCP port by default 8879"
}

###
### Parse command line arguments and set global variables
###
function parseArguments() {
    while [ "$1" != "" ]; do
        PARAM=$1
        shift
        VALUE=$1
                shift
        case $PARAM in
            -h | --help)
                usage
                exit
                ;;
            -targetNodeName)
                TARGET_NODE_NAME=$VALUE
                ;;
            -dmgrAdminUsername)
                DMGR_ADMIN_USER=$VALUE
                ;;
            -dmgrAdminPassword)
                DMGR_ADMIN_PASSWORD=$VALUE
                ;;
            -clusterPropertiesFile)
                PROPS_FILE_PATH=$VALUE
                D=$(dirname ${PROPS_FILE_PATH})
                B=$(basename ${PROPS_FILE_PATH})
                PROPS_FILE_PATH=$(cd ${D} 2>/dev/null && pwd || echo ${D})/$B
                ;;
            -dmgrHostName)
                DMGR_HOSTNAME=$VALUE
                ;;
            *)
                echo "ERROR: unknown parameter \"$PARAM\""
                usage
                exit 1
                ;;
        esac
     done
}

###################################
# Check if the specified parameter are "coherent"
###################################
function checkConfigurationValidity() {
    if [ -z $TARGET_NODE_NAME ]; then
        echo "Missing required parameter '-targetNodeName'"
        usage
        exit 1
    fi
    if [ -z $DMGR_ADMIN_USER ]; then
        echo "Missing required parameter '-dmgrAdminUsername'"
        usage
        exit  1
    fi
    if [ -z $DMGR_ADMIN_PASSWORD ]; then
        echo "Missing required parameter '-dmgrAdminPassord'"
        usage
        exit 1
    fi
    if [ -z $PROPS_FILE_PATH ]; then
        echo "Missing required parameter '-clusterPropertiesFile'"
        usage
        exit 1
    fi
    if [ ! -f $PROPS_FILE_PATH ]; then
        echo "The specified properties file does not exist! (${PROPS_FILE_PATH})"
        exit 1
    fi
}

###################################
# Starting deployment manager
###################################
function startDeploymenetManagerServer() {
    echo ""
    echo "Starting deployment manager ..."
    ${binDir}/startServer.sh dmgr
    echo ""
}

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

parseArguments "$@"
checkConfigurationValidity
startDeploymenetManagerServer
###################################
# Calling wsadmin
###################################

${WAS_HOME}/bin/ws_ant.sh -f ${binDir}/rules/addNodeToDCCluster.ant -Dwebsphere.clusterNodeName=${TARGET_NODE_NAME} -DwodmHome=${ODM_HOME} -Dwebsphere.user=${DMGR_ADMIN_USER} -Dwebsphere.password=${DMGR_ADMIN_PASSWORD} -DpropertiesFile=${PROPS_FILE_PATH}