#!/sbin/sh
##*************************************
##
## E.S.O. - VLT project
##
## "@(#) $Id: rtap,v 1.160 1999/04/14 09:31:52 vltsccm Exp $" 
##
## rtap"
## 
## who      when     what
##-------- -------- ------------------
##vltmgr 06/19/98 created for cmm
##
#
# Startup of rtap at boot time
# awalland   21/04/97
#
#******************************************************

PATH=/sbin:/usr/sbin:/usr/bin
export PATH

RTAPCONF=/etc/rc.config.d/rtap

rval=0

#
# Get actual configuration 
#

#
# RTAPROOT:           Directory where to find Rtap 
RTAPROOT=/opt/rtap/A.06.70

# RTAPENV:            Environment name
RTAPENV=`hostname`

# RTAPRUNNER:         Rtap started by this user
RTAPRUNNER=vlt

export RTAPROOT

case $1 in
start_msg)
        echo "Start Rtap Environment $RTAPENV"
        ;;

stop_msg)
        echo "Stop Rtap Environment $RTAPENV"
        ;;

'start')
        if [ -f $RTAPROOT/bin/RtapLicServer ] ; then
            $RTAPROOT/bin/RtapLicServer -n -1
        else
            echo "ERROR: $RTAPROOT/bin/RtapLicServer does not exist"
            rval=1
        fi

        /bin/su - $RTAPRUNNER -c '(setenv TZ UTC ; nohup vccEnvStart -e $RTAPENV -h $HOST 2>&1 &)' 

        ;;

'stop')
        /bin/su - $RTAPRUNNER -c '(setenv TZ UTC ; vccEnvStop -e $RTAPENV)'
        ;;

*)
        echo "usage: $0 {start|stop}"
        ;;
esac

exit $rval
