Date Created: Tue 07-Dec-2010

Related Document Categories:


    WebSphere 6.1 Binary Installation Scripts for Linux

    Some Sample scripts to help with Websphere 6.1 automated installs on Linux

    dmgr61.propsdmgr61_install.txtinstall.shnode6101.propsnode6102.propsresponsefile.base_dmgr61.txtresponsefile.base_node6101.txtresponsefile.base_node6102.txtresponsefile.updiinstaller.txt


    ============= install.sh =============

    #!/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 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 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 ${dm_target_dir}/bin
    echo "Running ${dm_target_dir}/bin/manageprofiles.sh from ${PWD}"
    echo "Running CMD: ./manageprofiles.sh -create -profileName ${DMGR_PROFILE_NAME} -profilePath ${dm_target_dir}/profiles -templatePath ${dm_target_dir}/profileTemplates/dmgr -cellName ${CELL_NAME} -hostName ${DMGR_HOST} -nodeName ${DMGR_NODE_NAME} -startingPort ${DMGR_START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin"
    ./manageprofiles.sh -create -profileName ${DMGR_PROFILE_NAME} -profilePath ${dm_target_dir}/profiles -templatePath ${dm_target_dir}/profileTemplates/dmgr -cellName ${CELL_NAME} -hostName ${DMGR_HOST} -nodeName ${DMGR_NODE_NAME} -startingPort ${DMGR_START_PORT} -isDefault -enableAdminSecurity true -adminUserName wasadmin -adminPassword wasadmin
    cat ${dm_target_dir}/profiles/logs/AboutThisProfile.txt
    chown -R was:was ${dm_target_dir}
    }

    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 [ "<"${RESPONSE_FILE}">" = "<>" ]; then
    echo "A response file must exist!"
    exit 1
    fi

    #Source the properties from the props file:
    getVars
    printVars

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

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

    #queryExisting

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

    #queryExisting
    #create_DM_Profile
    else

    #queryExisting

    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

Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

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

Oracle WebLogic Categories

JBoss Categories

Other Categories