set -x

DO_DEBUG=

if [ -z "$DO_DEBUG" ]
then
    DEBUG=
else
    DEBUG=" -Djava.security.debug=access"
fi

JINI_HOME=/usr/local/jini1_1

export CLASSPATH=.:$JINI_HOME/lib/jini-core.jar:$JINI_HOME/lib/jini-ext.jar:$JINI_HOME/lib/sun-util.jar

case $1 in
client) 
	class=client.ServiceViewer
	args="-Djava.rmi.server.codebase=http://`hostname`:80/classes/ \
     -Djava.security.policy=policy.all \
     $DEBUG \
     -Dnet.jini.discovery.debug=1 \
     -Djava.rmi.server.logCalls=true "
	;;
server) 
	class=services.Server
	args="-Djava.rmi.server.codebase=http://`hostname`:80/classes/ \
     -Djava.security.policy=policy.all \
     $DEBUG \
     -Dnet.jini.discovery.debug=1 \
     -Djava.rmi.server.logCalls=true "
	;;
esac

if [ $0 = "./run" ]
then 
    command=java
else
    command=jdb
fi
$command $args $class
