#!/bin/ksh -p

# $Id: runagent.ksh,v 1.1 2004/03/17 17:20:54 blaine Exp $
# This is a UNIX script for starting up a secured RMI Jmx ConnectorServer.

# Invoke like "nohup ./run.ksh"

export SECURITY_SETTINGS=
SECURITY_SETTINGS='-Djava.security.manager -Djava.security.policy==secure.policy'
#SECURITY_SETTINGS="$SECURITY_SETTINGS -Djava.security.debug=access.failure"

[ -e rmiregistry.pid ] && kill -INT $(<rmiregistry.pid) 2>&-
[ -e connsvr.pid ] && kill -INT $(<connsvr.pid) 2>&-
rm -f rmiregistry.pid connsvr.pid
sleep 1

export CLASSPATH=.:/usr/local/mx4j/lib/mx4j.jar:/usr/local/mx4j/lib/mx4j-remote.jar:tst.jar:offlimits

ksh -c 'echo $$ > rmiregistry.pid; exec rmiregistry 2003'&
ksh -c 'echo $$ > connsvr.pid;
exec java $SECURITY_SETTINGS BlainesAgent'> stdout.txt 2> stderr.txt &
