#!/bin/sh
#* ----------------------------------------------------------------------
#*               Proprietary and Confidential Information
#*
#* This material contains, and is part of a computer software program
#* which is, proprietary and confidential information owned by COMPUTER
#* ASSOCIATES INTERNATIONAL, INC.  The program, including this material,
#* may not be duplicated, disclosed or reproduced in whole or in part for
#* any purpose without the express written authorization of COMPUTER
#* ASSOCIATES. All authorized reproductions must be marked with this
#* legend.
#*
#*                          Copyright (c) 2005
#*             Computer Associates International, Incorporated
#*                          All rights reserved
#*
#* ----------------------------------------------------------------------
#*  SCCS Module Control Stamp
#* ----------------------------------------------------------------------
#
#* "@(#)CA-CCS	1.9  11/07/05 09:30:42"
#* "Copyright (C) 1992-2005 Computer Associates International, Inc.  All rights reserved."
#

### BEGIN INIT INFO
# CA Product Entry
# Provides:       CA-CCS
# Product Aliases: CCS ca-ccs ccs 
# Required-Start: +CA-ais +CA-alert +CA-atech +CA-cal +CA-cam +CA-cauwvdmn +CA-cci +CA-diadna +CA-diaukb +CA-discovery +CA-em +CA-emsrvc +CA-has +CA-help +CA-mcc +CA-opr +CA-snmp +CA-star +CA-tomcat +CA-wvubi +CA-wvmgr +postgres
# Required-Stop: +CA-ais +CA-alert +CA-wvubi +CA-atech +CA-cal +CA-cam +CA-cauwvdmn +CA-cci +CA-diadna +CA-diaukb +CA-discovery +CA-em +CA-emsrvc +CA-has +CA-help +CA-mcc +CA-opr +CA-snmp +CA-star +CA-tomcat +CA-wvmgr +postgres
# Default-Start:
# Default-Stop:
# chkconfig:
# Description:    CA SharedComponents
### END INIT INFO

### BEGIN CA STATUS HEADER
### END CA STATUS HEADER

PATH=/bin:/usr/bin:/sbin:$PATH
export PATH

ARG1=$1

if [ -f /etc/rc.status ] ; then
     . /etc/rc.status
     STARTPROC=/sbin/startproc
else
     if [ -f /etc/init.d/functions ];then
          . /etc/init.d/functions
     fi
fi

[ ! -f /etc/profile.CA ] && exit 4

case `uname -s` in
   Linux)
      ECHO="echo -e"
      ;;
   *)
      ECHO="echo"
      ;;
esac

#CA_SECTION=minimum; export CA_SECTION
. /etc/profile.CA 2> /dev/null
#unset CA_SECTION

CHECKPROC="$CASHCOMP/bin/parseps"
COMP="CA-CCS"

rc=0
case "$ARG1" in
     start_msg)
       $ECHO "Starting CA Common Services Layer"
       ;;
     start) 
       "$CASHCOMP/bin/unisrvcntr" start -X $COMP
       rc=$?
       "$CASHCOMP/bin/unistart" nsm3x
       rc=`expr $rc + $?`
       ;;
     stop_msg)
       $ECHO "Shutting down CA Common Services Layer"
       ;;
     stop) 
       "$CASHCOMP/bin/unishutdown" nsm3x
       rc=$?
       "$CASHCOMP/bin/unisrvcntr" shutdown -X $COMP
       rc=`expr $rc + $?`
       ;;
     restart)
       ## Stop the service and regardless of whether it was
       ## running or not, start it again.
       "$CASHCOMP/bin/unishutdown" nsm3x
       rc=$?
       "$CASHCOMP/bin/unisrvcntr" cycle $COMP
       rc=`expr $rc + $?`
       "$CASHCOMP/bin/unistart" nsm3x
       rc=`expr $rc + $?`
       ;;
     status)
       if [ "`uname -s`" = "Linux" ]; then
           Ppid=`cat /proc/$$/stat | awk ' {print $4} '`
           cmdline="`cat /proc/${Ppid}/cmdline`"
           [ "`echo $cmdline | grep "/sbin/service" | grep -- "--status-all"`" != "" ] && exit 0
       fi
       "$CASHCOMP/bin/unisrvcntr" status $COMP
       rc=$?
       ;;
     probe)
       ## Optional: Probe for the necessity of a reload,
       ## give out the argument which is required for a reload.
       ;;
     *)  
       $ECHO "Usage: $0 {start|stop|status|restart|probe}"
       exit 1
       ;;
esac

exit $rc
