#!/bin/sh
#------------------------------------------------------------------------------
#
# Sun ONE Web Server 6.1
#
# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# NOTE: To avoid your system from failing on reboot, do not change this
#       file in any way.
# This script is designed to be executed on reboot.
#
#------------------------------------------------------------------------------

# Make sure we have PATH set at this  point.
PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"

# Set this to 0, if you do NOT want autostart after a system reboot. 
S1WS_START_ONBOOT=1 

# Initialize Script scope level variables.
S1WS_HOME=%%%INSTANCE_ROOT%%%
S1WS_VERSION="6.1"

rc_failed="Failure"
rc_success="Success"

ret=$rc_success

# See how we were called.
case "$1" in
  	start_msg)
        	echo "Sun ONE Web Server $S1WS_VERSION starting ($S1WS_HOME)"
		;;
  	start)
		if [ -z "S1WS_START_ONBOOT" ] || [ "$S1WS_START_ONBOOT" = "0" ]; then
			ret=$rc_success
		else
        		echo "Sun ONE Web Server $S1WS_VERSION starting ($S1WS_HOME)"
			for each_server in $S1WS_HOME/https-*
			do
				if [ -d "$each_server" ]; then
			  		echo "  `basename $each_server`: \c"
			  		$each_server/start || ret=$rc_failed
			  		echo "$ret"
				fi
			done
		fi
        	;;
  	stop_msg)
        	echo "Sun ONE Web Server $S1WS_VERSION stopping ($S1WS_HOME)"
		;;
	stop)
		echo "Sun ONE Web Server $S1WS_VERSION stopping ($S1WS_HOME)"
		for each_server in $S1WS_HOME/https-*
		do
			reversed_list="$each_server $reversed_list"
		done
		for each_server in $reversed_list
		do
			if [ -d $each_server ]; then
			  echo   "  `basename $each_server`: \c "
			  $each_server/stop || ret=$rc_failed
			  echo "$ret"
			fi
		done
        	;;
    	restart)
       		$0 stop || return=$rc_failed
        	$0 start || return=$rc_failed
        	;;
    	*)
       		 echo "Usage: $0 {start|stop|restart}"
        	exit 1
        	;;
esac

# Inform the caller not only verbosely and set an exit status.
test "$ret" = "$rc_success" || exit 1
exit 0
