#!/bin/bash
# IBM Confidential
# OCO Source Materials
# 5724-V51
#
# (c) Copyright IBM Corp. 2000, 2008 All Rights Reserved.
#
# The source code for this program is not published or otherwise
# divested of its trade secrets, irrespective of what has been
# deposited with the U.S. Copyright Office.
if [ -d ${TOP} ]; then
    . ${TOP}/setup/init_ccd_vars.sh
else
    echo "\$TOP not defined!  Cannot continue."
    exit 99
fi

if [ ${WAS_VHOST} = "default_host" ]; then
    ${ECHO} "Please set WAS_VHOST to something other than 'default_host' before running this script."
    exit 99
fi

${ECHO}
${ECHO}
${ECHO} "Creating Virtual Host: ${WAS_VHOST} 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} "virtual host with the same name!"
${ECHO}
${ECHO} "Are you sure you want to do this? [y/N] "
read ret
case $ret in
    y|Y)
    ;;
    *)
        ${ECHO} Canceled!
        exit 1
    ;;
esac

case ${CCD_APPSVR} in
	websphere6)
            ${WAS_PROFILE_HOME}/bin/wsadmin.sh \
		-f ${TOP}/bin/websphere/create_vhost.jacl \
		${WAS_VHOST} \
		${_CCD_CONF_APPSVR_PORT} \
		${WAS_CELLNAME}
	;;

    *)
        ${ECHO} "$0: Error!: CCD_APPSVR set to \"$CCD_APPSVR\". Unknown value"
    ;;
esac
