#! /bin/bash
# ********************************************************************************************* 
# IRA Istituto di Radioastronomia                                                                      
# "@(#) $Id: escs,v 1.1 2010-08-13 06:54:06 a.orlati Exp $"
#
# This code is under GNU General Public Licence (GPL).                                              
#                                                                                                     
# Who                                when            What                                             
# Andrea Orlati(aorlati@ira.inaf.it) 12/08/2010      Creation                                  
#************************************************************************
#   NAME
# 
#   SYNOPSIS
# 
#   DESCRIPTION
#
#   FILES
#
#   ENVIRONMENT
#
#   RETURN VALUES
#
#   CAUTIONS
#
#   EXAMPLES
#
#   SEE ALSO
#
#   BUGS     
#

LONGOPTS=start,view,help
SHORTOPTS=svh
CL_START=
CL_VIEW=
CL_HELP=

function printUsage {
   echo "Gets the ESCS system started, management priviledges are needed"
   echo ""
        echo "Usage: `basename $0` [OPTIONS]  "
        echo "Options: "
        echo "   -s | --start   load the Command Center for starting the system"
        echo "   -v | --view    load the Command Center for monitoring purposes"
        echo "   -h | --help    prints this help"
}

# This simply checks for the correctness of the command line
export POSIXLY_CORRECT=1

getopt -n `basename $0` -Q -u -a -l $LONGOPTS $SHORTOPTS "$@" || {
   printUsage
   exit
}

# Now let's parse the command line
set -- `getopt -u -a -l $LONGOPTS $SHORTOPTS "$@"`

for i
do
	case "$i" in
		-h) CL_HELP=true ;;
		--help) CL_HELP=true ;;
		--view) CL_VIEW=true ;;
		-v) CL_VIEW=true ;;
		--start) CL_START=true ;;
		-s) CL_START=true ;;
		--)  break;;
	esac
	shift
done

# restore
export POSIXLY_CORRECT=
unset POSIXLY_CORRECT

if [ "$CL_HELP" ] ; then
   printUsage
   exit
fi

if [ "$CL_START" ] ; then
   acscommandcenter -r $INTROOT/app-defaults/nuragheStartup.xml &
   exit
fi

if [ "$CL_VIEW" ] ; then
   acscommandcenter corbaloc::192.168.200.200:3000/Manager &
fi



#
# ___oOo___
