#!/usr/bin/ksh
#
# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

typeset opt

while getopts 'R:G:Q:C:U:D:O:I:S:E:' opt
do
	case "$opt" in
		R)      RESOURCE=$OPTARG;;
		G)	RESOURCEGROUP=$OPTARG;;
		Q)	QMGR=$OPTARG;;
		C)	CLEANUP=$OPTARG;;
		D)	DB2INSTANCE=$OPTARG;;
		U)	USERID=$OPTARG;;
		O)	ORACLE_HOME=$OPTARG;;
		I)	ORACLE_SID=$OPTARG;;
		S)	START_COMMAND=$OPTARG;;
		E)	STOP_COMMAND=$OPTARG;;
		*)	logger -p daemon.err \
			"ERROR: `basename $0` Option $OPTARG unknown"
                        exit 1;;
	esac
done
    
. `dirname $0`/../etc/config
. `dirname $0`/functions

validate_options

debug_message "Method: `basename $0` - Begin"
$SET_DEBUG

rm $LOGFILE

validate

if [ "$rc_validate" -ne 0 ]
then
        debug_message "Method: `basename $0` - End (Exit 1)"
        exit 1
fi

check_qmgr

if [ "$rc_check_qmgr" -eq 0 ]
then
	create_dummy_process

	debug_message "Method: `basename $0` - End (Exit 0)"
	exit 0
fi

start_qmgr
		
if [ "$rc_strmqm" -eq 0 ]
then
	log_message notice "strmqm rc<$rc_strmqm>"
	debug_message "Method: `basename $0` - End (Exit 0)"
	exit 0
else
	log_message error "strmqm rc<$rc_strmqm>"
fi

debug_message "Method: `basename $0` - End (Exit 1)"

exit 1
