#!/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 CA, 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 CA. All authorized reproductions must be
#* marked with this legend.
#*
#*                      Copyright (c) 2006  CA, Inc.
#*                          All rights reserved
#*
#* ----------------------------------------------------------------------
#

# Start-up script for Message Queuing [CAM]
#

# allow undefined variables
set +u

if [ -z "$CAI_MSQ" ]
then
    if [ -f /etc/catngcampath ]
    then
        CAI_MSQ="`cat /etc/catngcampath`"
    else
        echo "CAM does not seem to be installed properly and fallback"
        echo "action cannot be taken to avoid the problem."
        echo " "
        exit 1
    fi
fi

# Check if already running
if [ -z "`ps -ef | grep cam | grep -v grep | grep -v rpm | grep -v cam[a-zA-Z0-9] | grep -v [a-zA-Z0-9]cam`" ]
then
    # Not already running, so attempt to start
    "$CAI_MSQ/bin/cam"

    if [ $? -ne 0 ]
    then
	    echo "Failed to start CAM Message Queuing Server"
	    exit 1
    fi
fi

exit 0

