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


#stop all services on localhost
#usage: stop_local.sh [--kill_rmi=no]

. ${TOP}/bin/get_params.sh

${ECHO} "stopping services on localhost"
$JAVA_RT com.ibm.ccd.admin.common.RootAdmin -cmd=stop_local

if  [ ! "${_CCD_KILL_RMI}" = "no" ]; then
    ${ADMIN_DIR}/abort/abort_rmiregistry.sh
fi

case ${CCD_APPSVR} in
    websphere6)
        if [ -n "${_CCD_APPSERVERNAMES}" ]; then
            n=1
            while [ -n "`${ECHO} ${_CCD_APPSERVERNAMES}|cut -f $n -d ,`" ];
            do
                $TOP/bin/go/stop/stop_appsvr.sh --svc_name=appsvr${n}_${SHORT_HOSTNAME} --appservername=`${ECHO} ${_CCD_APPSERVERNAMES}|cut -f $n -d ,`
                let n=$n+1
            done
        elif [ -z "${_CCD_APPSERVERS}" ]; then
            $TOP/bin/go/stop/stop_appsvr.sh
        elif [ ${_CCD_APPSERVERS} -gt 1 ]; then
            for ((n=1; n<=${_CCD_APPSERVERS}; n++)) 
            do
                $TOP/bin/go/stop/stop_appsvr.sh --svc_name=appsvr${n}_${SHORT_HOSTNAME} --appservername=${WAS_APPSERVERNAME}${n}
            done
        else
            $TOP/bin/go/stop/stop_appsvr.sh
        fi
    ;;
esac
