#!/usr/bin/ksh
#
# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
export DEBUG=ALL
typeset opt

while getopts 'R:G:' opt
do
        case "$opt" in
                R)      RESOURCE=$OPTARG;;
                G)      RESOURCEGROUP=$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 2>/dev/null

validate

if [ "$rc_validate" -ne 0 ]
then
        debug_message "Method: `basename $0` - End (Exit 1)"
        exit 1
fi
# make sure dced is running, use the tcl command to start the dce rpc server
start_dce

# first step in starting is stopping swa_rpcd if not alredy stopped
stop_swa_rpcd
	
	if [ "$rc_stop_swa_rpcd" -ne 0 ]; then
		log_message error "could not kill swa_rpcd "
		exit 1
	fi	
		check_hostrename
		if [ "$rc_check_hostrename" -ne 0 ]; then
			log_message error "error in configuration of SAA"
			exit 1
		fi
		start_swa_rpcd
		if [ "$rc_start_swa_rpcd" -ne 0 ]; then
			log_message error "could not start swa_rpcd, aborting"
			exit 1
		fi
		start_SAA

if [ "$rc_start_command" -eq 0 ]
then
        log_message notice "SAA start result code : $rc_start_command"

        debug_message "Method: `basename $0` - End (Exit 0)"
        exit 0
else
        log_message error "start_command rc<$rc_start_command>"
fi

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

exit 0
