#!/bin/bash
# Licensed Materials - Property of IBM
# 5724-I68
#
# (C) Copyright IBM Corp. 2000, 2006
#
# US Government Users Restricted Rights - Use, duplication, or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

if [ -d ${TOP} ]; then
    . ${TOP}/setup/init_ccd_vars.sh
else
    echo "\$TOP not defined!  Cannot continue."
    exit 99
fi

. ${TOP}/bin/get_params.sh
. ${ADMIN_DIR}/init_svc_vars.sh

${ECHO}
${ECHO}
${ECHO} "Creating application server for WebSphere Product Center: ${WAS_APPSERVERNAME} on node ${WAS_NODENAME}"

if [ -n "$WAS_SECURITY" ]; then
${ECHO}
${ECHO} "You have indicated that WAS security is enabled.  Please provide the"
${ECHO} "following authentication information:"
${ECHO} "WAS Username:"
read -p "> " WAS_USERNAME
${ECHO} "WAS Password (will not echo):"
read -p "> " -s WAS_PASSWORD
fi

${ECHO}
${ECHO} "Warning!  Running this script will erase any previously configured"
${ECHO} "application server with the same name!"
${ECHO}
${ECHO} "Are you sure you want to do this? [y/N] "
read ret
case $ret in
    y|Y)

	case ${CCD_APPSVR} in
		websphere)
                	echo "*** Error:  WebSphere 4 is no longer supported"
                	exit
		;;
		websphere5)
                	echo "*** Error:  WebSphere 5 is no longer supported"
                	exit
		;;
		websphere6)
			${WAS_PROFILE_HOME}/bin/wsadmin.sh \
				-f ${TOP}/bin/websphere/create_appsvr.jacl \
				${WAS_NODENAME} \
				${WAS_APPSERVERNAME} \
				${WAS_CELLNAME} \
				${_CCD_CONF_APPSVR_PORT}
		;;
		*)
			${ECHO} "*** Error: unknown application server ${CCD_APPSVR}"
			exit 99
		;;
	esac
    ;;
    *)
        ${ECHO} Canceled!
        exit 1
    ;;
esac

