Home | History | Annotate | Download | only in saa
      1 #
      2 # CDDL HEADER START
      3 #
      4 # The contents of this file are subject to the terms of the
      5 # Common Development and Distribution License (the License).
      6 # You may not use this file except in compliance with the License.
      7 #
      8 # You can obtain a copy of the license at usr/src/CDDL.txt
      9 # or http://www.opensolaris.org/os/licensing.
     10 # See the License for the specific language governing permissions
     11 # and limitations under the License.
     12 #
     13 # When distributing Covered Code, include this CDDL HEADER in each
     14 # file and include the License file at usr/src/CDDL.txt.
     15 # If applicable, add the following below this CDDL HEADER, with the
     16 # fields enclosed by brackets [] replaced with your own identifying
     17 # information: Portions Copyright [yyyy] [name of copyright owner]
     18 #
     19 # CDDL HEADER END
     20 #
     21 
     22 #
     23 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24 # Use is subject to license terms.
     25 #
     26 #
     27 #ident	"@(#)functions.ksh	1.10	08/07/21 SMI"
     28 #
     29 
     30 ZONENAME=/usr/bin/zonename
     31 
     32 SCLOGGER=/usr/cluster/lib/sc/scds_syslog
     33 SCHA_RESOURCE_GET=/usr/cluster/bin/scha_resource_get
     34 SCHA_RESOURCE_SETSTATUS=/usr/cluster/bin/scha_resource_setstatus
     35 PMFADM=/usr/cluster/bin/pmfadm
     36 
     37 PKG=SUNWscsaa
     38 METHOD=`basename $0`
     39 LOGFILE=/var/tmp/${RESOURCE}_logfile
     40 export PATH=/usr/bin:/bin:/usr/sbin
     41 export USR_SWA=/usr/swa                 # SWA instance information
     42 export ALL_ADM INST_NAME
     43 export ARCH=SunOS
     44 
     45 syslog_tag()
     46 {
     47         #
     48         # Data Service message format
     49         #
     50 
     51         ${SET_DEBUG}
     52 
     53         print "SC[${PKG:-??}.${METHOD:-??}]:${RESOURCEGROUP:-??}:${RESOURCE:-??}"
     54 }
     55 
     56 scds_syslog()
     57 {
     58 
     59         #
     60         # Log a message
     61         #
     62 
     63         $SET_DEBUG
     64 
     65         $SCLOGGER "$@" &
     66 }
     67 
     68 debug_message()
     69 {
     70         #
     71         # Output a debug message to syslog if required
     72         #
     73 
     74         if [ "$DEBUG" = "$RESOURCE" -o "$DEBUG" = "ALL" ]
     75         then
     76                 SET_DEBUG="set -x"
     77 
     78                 DEBUG_TEXT=$1
     79 
     80                 scds_syslog -p daemon.debug -t $(syslog_tag) -m \
     81                         "%s" "$DEBUG_TEXT"
     82         else
     83                 SET_DEBUG=
     84         fi
     85 }
     86 
     87 log_message()
     88 {
     89         #
     90         # Output a message to syslog as required
     91         #
     92 
     93         debug_message "Function: log_message - Begin"
     94         $SET_DEBUG
     95 
     96         if [ -s "${LOGFILE}" ]
     97         then
     98                 PRIORITY=$1
     99                 HEADER=$2
    100 
    101 		#
    102 		# Ensure the while loop only reads a closed file
    103 		#
    104 
    105 		strings ${LOGFILE} > ${LOGFILE}.copy
    106                 while read MSG_TXT
    107                 do
    108                         scds_syslog -p daemon.${PRIORITY} -t $(syslog_tag) -m \
    109                                 "%s - %s" \
    110                                 "${HEADER}" "${MSG_TXT}"
    111                 done < ${LOGFILE}.copy
    112 
    113 		cat /dev/null > ${LOGFILE} > /dev/null
    114 		cat /dev/null > ${LOGFILE}.copy
    115         fi
    116 
    117         debug_message "Function: log_message - End"
    118 }
    119 
    120 zone_function()
    121 {
    122 	debug_message "Function: zone_function - Begin"
    123 	${SET_DEBUG}
    124 
    125 	#
    126 	# Initialize PZONEOPT as empty
    127 	PZONEOPT=""
    128 
    129 	#
    130 	# If Solaris does not have /usr/bin/zonename just return 0
    131 	# else add "-z <zonename>" to PZONEOPT
    132 	#
    133 	if [ -x "${ZONENAME}" ];
    134 	then
    135 		PZONEOPT="-z `${ZONENAME}`"
    136 	fi
    137 
    138 	debug_message "Function: zone_function - End"
    139 	return 0
    140 }
    141 
    142 validate_options()
    143 {
    144         #
    145         # Ensure all options are set
    146         #
    147 
    148         for i in RESOURCE RESOURCEGROUP 
    149         do
    150                 case $i in
    151                         RESOURCE)
    152                         if [ -z ${RESOURCE} ]; then
    153                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    154                                 "ERROR: Option -%s not set" "R"
    155                                 exit 1
    156                         fi;;
    157 
    158                         RESOURCEGROUP)
    159                         if [ -z ${RESOURCEGROUP} ]; then
    160                                 scds_syslog -p daemon.err -t $(syslog_tag) -m \
    161                                 "ERROR: Option -%s not set" "G"
    162                                 exit 1
    163                         fi;;
    164                 esac
    165         done
    166 }
    167 
    168 validate()
    169 {
    170 	#
    171 	# Validate SAA
    172 	#
    173 	
    174         debug_message "Function: validate - Begin"
    175 	${SET_DEBUG}
    176 
    177 	rc_validate=0
    178 
    179 	#
    180 	# Validate that ${filename} exists
    181 	#
    182 	filename="${USR_SWA}/insts"
    183 
    184 	if [ ! -f "${filename}" ]
    185 	then
    186    		scds_syslog -p daemon.error -t $(syslog_tag) -m \
    187 			"Validate - file %s does not exist" \
    188 			"${filename}"
    189 		rc_validate=1
    190 	else
    191 		debug_message "Validate - ${filename} exists"
    192 	fi
    193 
    194 	#
    195 	# For SAA 6.2 enforce that the agent does only support one
    196 	# SAA instance.
    197 	#
    198 	if [ "$(/bin/cat ${filename} | /bin/awk '{print $2}' | /bin/cut -c 2-4 | /bin/uniq)" = "6.2" ]
    199 	then
    200 		if [ "$(/bin/cat ${filename} | /bin/wc -l)" -ne 1 ]
    201 		then
    202 			# SCMSGS
    203 			# @explanation
    204 			# The agent does only support exactly one
    205 			# SWIFTAlliance Access instance.
    206 			# @user_action
    207 			# Verify that the file /usr/swa/insts does only contain
    208 			# one line describing the SWIFTAlliance Access instance.
    209 			scds_syslog -p daemon.error -t $(syslog_tag) -m \
    210 				"Validate - %s must contain exactly one SWIFTAlliance Access instance" \
    211 				"${filename}"
    212 			rc_validate=1
    213 		fi
    214 	fi
    215 
    216 	debug_message "Function: validate - End"
    217 }
    218 
    219 start_dce()
    220 {
    221 	#
    222 	# Start dce
    223 	#
    224 
    225         debug_message "Function: start_dce - Begin"
    226 	$SET_DEBUG
    227 	
    228 	#
    229 	# This should take care of sh, ksh, csh, tcsh and bash
    230 	#
    231 	/opt/dce/tcl/start.dce >> $LOGFILE 2>&1
    232 	rc_start_dce=$?
    233 
    234 	debug_message "Function: start_dce - End"
    235 }
    236 
    237 stop_dce()
    238 {
    239 	#
    240 	# Stop dce
    241 	#
    242 
    243         debug_message "Function: stop_dce - Begin"
    244 	$SET_DEBUG
    245 
    246 	/opt/dce/tcl/stop.dce >> $LOGFILE 2>&1
    247 	rc_stop_dce=$?
    248 	
    249 	debug_message "Function: stop_dce - End"
    250 }
    251 
    252 check_dce()
    253 {
    254 	# 
    255 	# Probe dce
    256 	#
    257 
    258         debug_message "Function: check_dce - Begin"
    259 	$SET_DEBUG
    260 
    261 	rc_check_dce=0
    262 
    263 	RESULT=`/opt/dce/tcl/show.cfg | grep RPC | awk ' {print $3}'`
    264 
    265 	case "$RESULT" in
    266 		'Not')
    267         		#can not connect to dced assuming it is dead
    268         		#print "ERROR    dced is dead"
    269         		rc_check_dce=1
    270         	;;
    271 		'Running')
    272         		#no problemmo  dced is running fine
    273         		rc_check_dce=0
    274         	;;
    275 	esac
    276 	
    277 	debug_message "Function: check_dce - End"
    278 }
    279 
    280 get_SAA_version()
    281 {
    282 	debug_message "Function: get_SAA_version - Begin"
    283 	${SET_DEBUG}
    284 
    285 	#
    286 	# as of version 5.9 of SAA, no more dce client needed... so version is checked here..
    287 	# to determine correct startup
    288 	#
    289 	saa_version=`cat ${USR_SWA}/insts | awk '{print $2}' |cut -c 2-4 |uniq`
    290 	saa_major=`echo $saa_version | cut -d "." -f 1`
    291 	saa_minor=`echo $saa_version | cut -d "." -f 2`
    292 	if [ $saa_major -le 5 ] ; then
    293 		# rev is 5, checking for special version ( pre 6 )
    294 		if [ $saa_minor -eq 9 ] && [ $saa_major -eq 5 ]; then
    295 			# found the pre-6 release of saa... turning off dce
    296 			use_dce=0
    297 		else
    298 			# release is below 5.9... using dce
    299 			use_dce=1
    300 		fi
    301 	else
    302 		#revision is higer than 5... no need for dce anymore
    303 		use_dce=0
    304 	fi
    305 	export use_dce
    306 
    307 	debug_message "Function: get_SAA_version - End"
    308 }
    309 
    310 start_SAA()
    311 {
    312 	#
    313 	# Start SAA
    314 	#
    315 
    316         debug_message "Function: start_SAA - Begin"
    317 	${SET_DEBUG}
    318 
    319 	# initialize PZONEOPT
    320 	zone_function
    321 
    322 	while read TEMP1 TEMP2 TEMP3 ALL_ADM TEMP5 INST_NAME TEMP7
    323 	do
    324 		( 
    325 		if [ -f ${USR_SWA}/alliance_init ]
    326 		then
    327         		. ${USR_SWA}/alliance_init -s -i "${INST_NAME}"
    328 			${ALLIANCE}/INS/bin/${ARCH}/rc.alliance start &
    329 			rc_start_command=$?
    330 		else
    331 			rc_start_command=100
    332 			
    333 		fi
    334 
    335 		#
    336 		# First wait for a_start_server to appear.
    337 		#
    338 		while true
    339 		do
    340 			if pgrep ${PZONEOPT} -u ${ALL_ADM} '^a_start_server$' > /dev/null
    341 			then
    342 				break
    343 			else 
    344 				sleep 3
    345 			fi
    346 		done
    347 
    348 		#
    349 		# Loop until a_start_server disappears again.
    350 		# To be sure not to return until saa is really started.
    351 		#
    352 		while true
    353 		do
    354 			if pgrep ${PZONEOPT} -u ${ALL_ADM} '^a_start_server$' > /dev/null
    355 			then
    356 				debug_message "saa server still starting... wait"
    357 				sleep 3
    358 			else
    359 				debug_message "saa server start script is not running anymore"
    360 				break
    361 			fi
    362 		done ) >> $LOGFILE 2>&1
    363 		
    364 	done < ${USR_SWA}/insts
    365 
    366 	debug_message "Function: start_SAA - End"
    367 }
    368 
    369 check_hostrename()
    370 {
    371 	debug_message "Function: check_hostrename - Begin"
    372 	${SET_DEBUG}
    373 
    374 	rc_check_hostrename=0
    375 	while read TEMP1 TEMP2 TEMP3 ALL_ADM TEMP5 INST_NAME TEMP7
    376 	do
    377 		if [ -f "${USR_SWA}/alliance_init" ]; then
    378 			# call routine to see if the instance is running
    379 			check_inst_running
    380 				if [ "$rc_check_running" -eq 0 ]; then
    381 					debug_message "Instance $INST_NAME servers is running"
    382 				else
    383 					/bin/su $ALL_ADM -c '
    384 					export HOME=~$ALL_ADM
    385 					. $USR_SWA/alliance_init -s -i "$INST_NAME"
    386 					# Clean-up Alliance db (rename host)
    387 
    388 					echo "Making SWIFTAlliance $INST_NAME ready"
    389 					TO_HOST=`hostname`
    390 					FROM_HOST=`cat $ALLIANCE_DB/.alliance_host`
    391 					$ALLIANCE/BSS/bin/$ARCH/alliance hostrename "$FROM_HOST" "$TO_HOST"
    392 					exit
    393 					' >> $LOGFILE 2>&1
    394 					debug_message "Ended SWIFTAlliance host rename"
    395 				fi
    396 		else
    397 			debug_message "Can not find ${USR_SWA}/alliance_init for instance ${INST_NAME}"
    398 			rc_check_hostrename=100
    399 		fi
    400 	done < $USR_SWA/insts
    401 
    402 	debug_message "Function: check_hostrename - End"
    403 }
    404 
    405 check_inst_running()
    406 {	
    407 	debug_message "Function: check_inst_running - Begin"
    408 	$SET_DEBUG
    409 
    410 	/bin/su ${ALL_ADM} -c '
    411  		export HOME=~${ALL_ADM}
    412 		. ${USR_SWA}/alliance_init -s -i "${INST_NAME}"
    413 
    414 		echo "Checking if SWIFTAlliance instance ${INST_NAME} is running"
    415 		export LIBPATH=${ALLIANCE}/common/lib/${ARCH}:${ALLIANCE}/BSS/lib/${ARCH}
    416 		${ALLIANCE}/BSS/bin/${ARCH}/alliance -E ${ALLIANCE}/BSS/bin/${ARCH}/is_listening -- -- -P /BS_csys -T 10' >> ${LOGFILE} 2>&1
    417 
    418 	if [ $? -ne 0 ]
    419 	then
    420 		debug_message "SWIFTAlliance instance ${INST_NAME} not running"
    421 		rc_check_running=100
    422 	else
    423 		debug_message "SWIFTAlliance instance ${INST_NAME} is running"
    424 		rc_check_running=0
    425 	fi
    426 
    427 	debug_message "Function: check_inst_running - End"
    428 }
    429 
    430 start_swa_boot()
    431 {
    432 	debug_message "Function: start_swa_boot - Begin"
    433 	$SET_DEBUG
    434 
    435 	# Check if /etc/init.d/rc.swa_boot exists
    436 	# needed for 5.9 and higher
    437 	if [ -f /etc/init.d/rc.swa_boot ]
    438 	then
    439 		debug_message "Starting SWIFTAlliance swa_boot process"
    440 		/etc/init.d/rc.swa_boot start >> $LOGFILE 2>&1
    441 		rc_start_swa_boot=$?
    442 	else
    443 		debug_message "Can not find /etc/init.d/rc.swa_boot"
    444 		rc_start_swa_boot=100
    445 	fi
    446 
    447 	debug_message "Function: start_swa_boot - End"
    448 }
    449 
    450 stop_swa_boot()
    451 {
    452 	debug_message "Function: stop_swa_boot - Begin"
    453 	$SET_DEBUG
    454 
    455 	# Check if /etc/init.d/rc.swa_boot exists
    456 	# needed for 5.9 and higher
    457 	if [ -f /etc/init.d/rc.swa_boot ]
    458 	then
    459 		debug_message "Starting SWIFTAlliance swa_boot process"
    460 		/etc/init.d/rc.swa_boot stop >> $LOGFILE 2>&1
    461 		rc_stop_swa_boot=$?
    462 	else
    463 		debug_message "Can not find /etc/init.d/rc.swa_boot"
    464 		rc_stop_swa_boot=100
    465 	fi
    466 
    467 	debug_message "Function: stop_swa_boot - End"
    468 }
    469 
    470 start_swa_rpcd()
    471 {
    472 	debug_message "Function: start_swa_rpcd - Begin"
    473 	$SET_DEBUG
    474 
    475 	#check if file exists
    476 	if [ -f $USR_SWA/swa_rpcd ]
    477 	then 
    478 		debug_message "Starting SWIFTAlliance rpc process"
    479 		$USR_SWA/swa_rpcd >> $LOGFILE 2>&1
    480 		rc_start_swa_rpcd=$?
    481 	else
    482 		debug_message "can not find $USR_SWA/swa_rpcd"
    483 		rc_start_swa_rpcd=100
    484 	fi
    485 
    486 	debug_message "Function: start_swa_rpcd - End"
    487 }
    488 
    489 stop_swa_rpcd()
    490 {
    491 	debug_message "Function: stop_swa_rpcd - Begin"
    492 	${SET_DEBUG}
    493 
    494 	# initialize PZONEOPT
    495 	zone_function
    496 
    497 	SWA_PID=`pgrep ${PZONEOPT} -u ${ALL_ADM} '^swa_rpcd$'`
    498 	if [ -n "${SWA_PID}" ]
    499 	then
    500 		if [ -z ${SWA_PID} ]
    501 		then
    502 			debug_message "no swa_rpcd running"
    503 			rc_stop_swa_rpcd=0
    504 		else
    505         		kill -KILL ${SWA_PID} >> ${LOGFILE} 2>&1
    506         		if [ $? -ne 0 ]
    507         		then
    508         		        debug_message "Cannot kill swa_rpcd process (pid ${SWA_PID})"
    509         		        rc_stop_swa_rpcd=100
    510         		else
    511         		        sleep 2
    512 				rc_stop_swa_rpcd=0
    513         		fi
    514 		fi
    515 	fi
    516 
    517 	debug_message "Function: stop_swa_rpcd - End"
    518 }
    519 
    520 stop_SAA()
    521 {
    522 	#
    523 	# Stop SAA
    524 	#
    525 
    526         debug_message "Function: stop_SAA - Begin"
    527 	$SET_DEBUG
    528 
    529 	# initialize PZONEOPT
    530 	zone_function
    531 
    532 	rc_stop_command=0
    533 
    534 	while read TEMP1 TEMP2 TEMP3 ALL_ADM TEMP5 INST_NAME TEMP7
    535 	do
    536 		(
    537 		check_inst_running
    538 		if [ "$rc_check_running" -ne 0 ]
    539 		then
    540 			# empty line
    541 			echo "SWIFTAlliance instance $INST_NAME not running"
    542 			do_nothing=0
    543 		else
    544 			echo "Stopping SWIFTAlliance instance $INST_NAME"
    545 			. $USR_SWA/alliance_init -s -i "$INST_NAME"
    546 			/bin/su $ALL_ADM -c ' $ALLIANCE/BSS/bin/$ARCH/alliance stop_server
    547 
    548 			if [ $? -ne 0 ]
    549 			then
    550 				echo "Could not stop SWIFTAlliance instance ${INST_NAME}"
    551 				rc_stop_command=1
    552 				return 1
    553 			else
    554 				echo "Successfully stopped SWIFTAlliance instance $INST_NAME"
    555 			fi
    556 
    557 			if [ -f $ALLIANCE/BSS/bin/$ARCH/select_swnet_inst ]
    558 			then
    559 				SELECTED=`$ALLIANCE/BSS/bin/$ARCH/alliance -E $ALLIANCE/BSS/bin/$ARCH/select_swnet_inst -- -- -E -R 2>&1 1>/dev/null`
    560 				if [ $? -ne 0 ]
    561 				then
    562 					echo "SWIFTAlliance $SELECTED - no SNL"
    563 				else
    564 					echo "Setting SNL environment - $SELECTED"
    565 					eval $SELECTED
    566 					export PATH=$PATH:$SWNET_HOME/bin
    567 					. swiftnet init
    568 
    569 					echo "Stopping SNL"
    570 					swiftnet stop
    571 
    572 					# clean_ipc does not exist when RA is used
    573 					if [ -f $SWNET_HOME/bin/clean_ipc ]
    574 					then
    575 						clean_ipc 1>/dev/null
    576 					fi
    577 				fi
    578 				
    579 			fi '
    580 		fi ) >> $LOGFILE 2>&1
    581 		
    582 		#### loop over the processes until they dont exist.
    583 		###################################################
    584 		while true
    585 		do
    586 			if pgrep ${PZONEOPT} -u ${ALL_ADM} '^a_stop_server$' > /dev/null
    587 			then
    588 				debug_message "In STOP waiting for stop of processes"
    589 				sleep 10
    590 			else
    591 				break
    592 			fi
    593 		done
    594 	
    595 	done < $USR_SWA/insts
    596 
    597 	debug_message "Function: stop_SAA - End"
    598 }
    599 
    600 check_SAA()
    601 {
    602 	# 
    603 	# Probe SAA
    604 	#
    605 
    606         debug_message "Function: check_SAA - Begin"
    607 	$SET_DEBUG
    608 
    609 	###################################
    610 	# As required by SWIFT, no monitoring of the application is done by
    611 	# default since application control is kept in the SAA admin console.
    612 	# The cluster is used to be able to automate the SAA failover in case of 
    613 	# failures of the framework. Sun Cluster will not care about the
    614 	# application but fail it over, on demand, or when network or
    615 	# hardware failure occurs.
    616 	#
    617 	# If a full probe is required, and then manual application intervention
    618 	# is prohibited, a full probe can get achieved by setting
    619 	# PERFORM_REAL_MONITORING=1
    620 	# within /opt/SUNWscsaa/util/saa_config and re-registering the resource.
    621 	###################################
    622 
    623 	while read TEMP1 TEMP2 TEMP3 ALL_ADM TEMP5 INST_NAME TEMP7
    624 	do
    625 		if pgrep -u root -f "start_SAA .*-R ${RESOURCE} " >/dev/null
    626 		then
    627 			rc_check_SAA=100
    628 			return 100
    629 		else
    630 			rc_check_SAA=0
    631 		fi
    632 
    633 		check_inst_running
    634 	done < $USR_SWA/insts
    635 
    636 	if [ "${rc_check_running}" -ne 0 ]; then
    637 		${SCHA_RESOURCE_SETSTATUS} -G ${RESOURCEGROUP} -R ${RESOURCE} -s DEGRADED -m "SAA Instance offline"
    638 
    639 		if [ "${PERFORM_REAL_MONITORING}" -ne 0 ]; then
    640 			rc_check_SAA=100
    641 		fi
    642 	else
    643 		${SCHA_RESOURCE_SETSTATUS} -G ${RESOURCEGROUP} -R ${RESOURCE} -s OK -m "SAA Instance online"
    644 	fi
    645 
    646 	debug_message "Function: check_SAA - End"
    647 }
    648 
    649 start_DB_SAA()
    650 {
    651 	#
    652 	# Start swa_boot, embedded database and SAA instance
    653 	#
    654 
    655 	debug_message "Function: start_DB_SAA - Begin"
    656 	${SET_DEBUG}
    657 
    658 	rc_start_command=0
    659 
    660 	# Make sure the required entries within /etc/services exist
    661 	# by calling /usr/swa/apply_alliance_ports
    662 	APPLY_ALLIANCE_PORTS_CMD=${USR_SWA}/apply_alliance_ports
    663 	if [ -x ${APPLY_ALLIANCE_PORTS_CMD} ]
    664 	then
    665 		${APPLY_ALLIANCE_PORTS_CMD} >> ${LOGFILE} 2>&1
    666 	else
    667 		# SCMSGS
    668 		# @explanation
    669 		# The command /usr/swa/apply_alliance_ports does not
    670 		# exist but is required for SWIFTAlliance Access to
    671 		# properly function.
    672 		# @user_action
    673 		# Verify the SWIFTAlliance Access instrallation and make
    674 		# sure /usr/swa/apply_alliance_ports does exist.
    675 		scds_syslog -p daemon.error -t $(syslog_tag) -m \
    676 			"start_DB_SAA - Command %s does not exist" \
    677 			"${APPLY_ALLIANCE_PORTS_CMD}"
    678 		rc_start_command=1
    679 		debug_message "Function: start_DB_SAA - End"
    680 		return 1
    681 	fi
    682 
    683 	# Initialize instance information from /usr/swa/insts into variables
    684 	/bin/cat ${USR_SWA}/insts | read INST_HOME INST_VERSION T1 SAA_OWNER T2 INST_NAME T3
    685 
    686 	# start swa_boot process
    687 	if [ -x ${INST_HOME}/bin/saa_bootstrap ]
    688 	then
    689 		/bin/su ${SAA_OWNER} -c "${INST_HOME}/bin/saa_bootstrap -nameservice start" >> ${LOGFILE} 2>&1
    690 		if [ $? -ne 0 ]
    691 		then
    692 			rc_start_command=1
    693 			debug_message "Function: start_DB_SAA - End"
    694 			return 1
    695 		fi
    696 	else
    697 		# SCMSGS
    698 		# @explanation
    699 		# The referenced command is not executable or does not
    700 		# exist, but is required for SWIFTAlliance Access to
    701 		# properly function.
    702 		# @user_action
    703 		# Verify the SWIFTAlliance Access instrallation and make
    704 		# sure the referenced command does exist and is executable.
    705 		scds_syslog -p daemon.error -t $(syslog_tag) -m \
    706 			"start_DB_SAA - Command %s does not exist or is not executable" \
    707 			"${INST_HOME}/bin/saa_bootstrap"
    708 		rc_start_command=1
    709 		debug_message "Function: start_DB_SAA - End"
    710 		return 1
    711 	fi
    712 
    713 	# start SAA embedded DB and instance
    714 	if [ -x ${USR_SWA}/alliance_init ]
    715         then
    716 		. ${USR_SWA}/alliance_init -s -i "${INST_NAME}" >> ${LOGFILE} 2>&1
    717 		/bin/su ${SAA_OWNER} -c "${INST_HOME}/bin/saa_bootstrap -saastart start" >> ${LOGFILE} 2>&1
    718 		rc_start_command=$?
    719 	else
    720 		scds_syslog -p daemon.error -t $(syslog_tag) -m \
    721 			"start_DB_SAA - Command %s does not exist or is not executable" \
    722 			"${USR_SWA}/alliance_init"
    723 		rc_start_command=1
    724 		debug_message "Function: start_DB_SAA - End"
    725 		return 1
    726 	fi
    727 	
    728 	debug_message "Function: start_DB_SAA - End"
    729 }
    730 
    731 stop_DB_SAA()
    732 {
    733 	#
    734 	# Stop SAA instance, embedded database and swa_boot
    735 	#
    736 
    737 	debug_message "Function: stop_DB_SAA - Begin"
    738 	${SET_DEBUG}
    739 
    740 	rc_stop_command=0
    741 
    742 	# Initialize instance information from /usr/swa/insts into variables
    743 	/bin/cat ${USR_SWA}/insts | read INST_HOME INST_VERSION T1 SAA_OWNER T2 INST_NAME T3
    744 
    745 	# stop SAA embedded DB and instance
    746 	if [ -x ${USR_SWA}/alliance_init -a -x ${INST_HOME}/bin/saa_bootstrap ]
    747         then
    748 		. ${USR_SWA}/alliance_init -s -i "${INST_NAME}" >> ${LOGFILE} 2>&1
    749 		/bin/su ${SAA_OWNER} -c "${INST_HOME}/bin/saa_bootstrap stop" >> ${LOGFILE} 2>&1
    750 		rc_stop_command=$?
    751 	else
    752 		# SCMSGS
    753 		# @explanation
    754 		# The referenced commands are either not executable or do not
    755 		# exist, but are required for SWIFTAlliance Access to
    756 		# properly function.
    757 		# @user_action
    758 		# Verify the SWIFTAlliance Access instrallation and make
    759 		# sure the referenced commands do exist and are executable.
    760 		scds_syslog -p daemon.error -t $(syslog_tag) -m \
    761 			"stop_DB_SAA - Command %s and/or %s do not exist or are not executable" \
    762 			"${USR_SWA}/alliance_init" "${INST_HOME}/bin/saa_bootstrap"
    763 		rc_stop_command=1
    764 		debug_message "Function: stop_DB_SAA - End"
    765 		return 1
    766 	fi
    767 
    768 	# stop swa_boot process
    769 	/bin/su ${SAA_OWNER} -c "${INST_HOME}/bin/saa_bootstrap -nameservice stop" >> ${LOGFILE} 2>&1
    770 	if [ $? -ne 0 ]
    771 	then
    772 		rc_stop_command=1
    773 	fi
    774 
    775 	debug_message "Function: stop_DB_SAA - End"
    776 }
    777 
    778 check_DB_SAA()
    779 {
    780 	#
    781 	# Check SAA instance and implicitly the embedded database
    782 	#
    783 
    784 	debug_message "Function: check_DB_SAA - Begin"
    785 	${SET_DEBUG}
    786 
    787 	###################################
    788 	# As required by SWIFT, no monitoring of the application is done by
    789 	# default since application control is kept in the SAA admin console.
    790 	# The cluster is used to be able to automate the SAA failover in case
    791 	# of failures of the framework. Sun Cluster will not care about the
    792 	# application but fail it over, on demand, or when network or
    793 	# hardware failure occurs.
    794 	#
    795 	# If a full probe is required, and then manual application intervention
    796 	# is prohibited, a full probe can get achieved by setting
    797 	# PERFORM_REAL_MONITORING=1
    798 	# within /opt/SUNWscsaa/util/saa_config and re-registering the resource.
    799 	###################################
    800 	rc_check_SAA=0
    801 
    802 	# check if the start_SAA script is still running
    803 	# this implements wait-for-online, to make sure the start_SAA script
    804 	# finished before further probing the SAA instance
    805 	if pgrep -u root -f "start_SAA .*-R ${RESOURCE} " >/dev/null
    806 	then
    807 		rc_check_SAA=100
    808 		debug_message "Function: check_DB_SAA - End"
    809 		return 100
    810 	fi
    811 
    812 	# Initialize instance information from /usr/swa/insts into variables
    813 	/bin/cat ${USR_SWA}/insts | read INST_HOME INST_VERSION T1 SAA_OWNER T2 INST_NAME T3
    814 
    815 	# Check if the SAA instance is running. This implicitly checks also
    816 	# if the embedded database is running.
    817 	# On faliure, by default only update the status message to indicate
    818 	# if the SAA instance is online or offline.
    819 	if [ -x ${USR_SWA}/alliance_init -a -x ${INST_HOME}/BSS/bin/${ARCH}/alliance -a -x ${INST_HOME}/BSS/bin/${ARCH}/is_listening ]
    820         then
    821 		. ${USR_SWA}/alliance_init -s -i "${INST_NAME}" > /dev/null 2>&1
    822 		/bin/su ${SAA_OWNER} -c "${INST_HOME}/BSS/bin/${ARCH}/alliance -E ${INST_HOME}/BSS/bin/${ARCH}/is_listening -- -- -P /BS_csys -T 10" > /dev/null 2>&1
    823 		if [ $? -ne 0 ]
    824 		then
    825 			${SCHA_RESOURCE_SETSTATUS} -G ${RESOURCEGROUP} -R ${RESOURCE} -s DEGRADED -m "SAA Instance offline"
    826 			if [ "${PERFORM_REAL_MONITORING}" -ne 0 ]
    827 			then
    828 				rc_check_SAA=100
    829 			fi
    830 		else
    831 			${SCHA_RESOURCE_SETSTATUS} -G ${RESOURCEGROUP} -R ${RESOURCE} -s OK -m "SAA Instance online"
    832 		fi
    833 	fi
    834 
    835 	debug_message "Function: check_DB_SAA - End"
    836 }
    837