#!/bin/sh
# -----------------------------------------------------------------------
# Main script for firing up ViewServer
# Usage: start_viewserver [options]
#
# options:
#
#	-d 	debug
#	-p	port
#	
# -----------------------------------------------------------------------

# This is written by configure: do not modify
MORE_ARGS="yes"
DEBUG="0"
JAVA_RUN_ARGS=""
PORT="17726"

if [ $# -gt 0 ] ; then

  if [ $1 = -h ] ; then
	echo "Usage: startup_viewserver [options]"
	echo "  options:"
	echo 
	echo "    -h              print usage help"
	echo "    -p <port>       port number"
	echo "    -d <debugMode>  debug mode: ( 1:run debugger, 2:attach debugger manually )"
	echo "    -java <args>    additional args to java command"
	echo	
	exit 0
  fi

  while [ $MORE_ARGS = "yes" ] ; do
    MORE_ARGS="no"

    if [ $1 = "-d" ] ; then
      MORE_ARGS="yes"
      shift
      DEBUG="$1"
      shift
      echo "In debug mode:"
    fi


    if [ $1 = "-p" ] ; then
      MORE_ARGS="yes"
      shift
      PORT="$1"
      shift
    fi

    if [ $1 = "-java" ] ; then
      MORE_ARGS="yes"
      shift
      JAVA_RUN_ARGS="$JAVA_RUN_ARGS $1"
      shift
    fi

    if [ $1 = "-v" ] ; then
      MORE_ARGS="yes"
      shift
      JAVA_RUN_ARGS="$JAVA_RUN_ARGS -verbose"
    fi

  done

fi		

APP_ARGS=" $PORT "
export APP_ARGS
export JAVA_RUN_ARGS

sme_execute_class miiee.dataview.ViewserverControlPanel $DEBUG

exit 0		
