#!/bin/sh
#
# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.

#pragma ident	"@(#)jsas_utils.sh	1.1	04/10/04 SMI"

#
# What:
#	This script is used to check for the status
#	of the DAS server .  
#
# The "asadmin list-domains" gives the status of the
# DAS process as shown below
# -------------------------------------------------------
# bash-2.05# ./asadmin list-domains --domaindir /dg1/domain
# List of domains:
# new-domain running
# -------------------------------------------------------
# We use /usr/bin/grep to get the status.
# return 0 if DAS is running  or 1 if DAS is "not running"
#
# Return Value:
#	0 If DAS is running
#	1 If DAS is not running
#set -x

PATH=/bin:/usr/bin:/usr/cluster/bin:/usr/sbin:/usr/cluster/lib/sc:$PATH;export PATH
syslog_tag="SC[SUNW.jsas,jsas_utils]"

# Checking the command syntax

if [ $# -ne 3 ]
then
	scds_syslog -p error -t $syslog_tag -m \
		 "INTERNAL ERROR usage:$0 install_dir domaindir domain_name"
	exit 1
fi


INSTALL_DIR=$1
DOMAIN_DIR=$2
DOMAIN_NAME=$3

$INSTALL_DIR/appserver/bin/asadmin list-domains --domaindir $DOMAIN_DIR | /usr/bin/grep -i $DOMAIN_NAME | /usr/bin/grep -i running | grep -v not > /dev/null
rc=$?

if [ $rc -ne 0 ]
then
	exit 1
else
	exit 0
fi
