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

# 
# # Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# # IBM makes no representations or warranties about the suitability of
# # this program, either express or implied, including but not limited to
# # the implied warranties of merchantability, fitness for a particular
# # purpose, or non-infringement. 
# 
#


. ${TOP}/bin/get_params.sh
SVC_NAME=appsvr_${SHORT_HOSTNAME}
. ${ADMIN_DIR}/init_svc_vars.sh

case "${CCD_APPSVR}" in
    websphereAE)
        ${WAS_HOME}/bin/wscp.sh -p ${TOP}/etc/default/websphere/wscp.properties -f ${ADMIN_DIR}/websphere/abort.tcl ${WAS_NODENAME} ${WAS_APPSERVERNAME}
    ;;
    websphere5)
        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
            ${ECHO}
            ${WAS_HOME}/bin/stopServer.sh ${WAS_APPSERVERNAME} -username $WAS_USERNAME -password $WAS_PASSWORD
        else
            ${WAS_HOME}/bin/stopServer.sh ${WAS_APPSERVERNAME}
        fi
    ;;
    websphere6)
        InitEtcDirForAppSvr websphere
        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
            ${ECHO}
            ${WAS_PROFILE_HOME}/bin/stopServer.sh ${WAS_APPSERVERNAME} -username $WAS_USERNAME -password $WAS_PASSWORD
        else
            ${WAS_PROFILE_HOME}/bin/stopServer.sh ${WAS_APPSERVERNAME}
        fi
    ;;

    *)
    
    ;;
esac

${ADMIN_DIR}/abort/abort_svc.sh --svc_name=${_CCD_SVC_NAME=appsvr_${SHORT_HOSTNAME}} --unbind=${_CCD_UNBIND}
