#!/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

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
	websphereAE)
		echo "*** Error:  WebSphere AE is no longer supported"
		exit 
	;;
	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_vhost.jacl \
		${WAS_VHOST} \
		${_CCD_CONF_APPSVR_PORT} \
		${WAS_CELLNAME}
	;;
esac
