#!/bin/sh

MICORC=/dev/null
export MICORC

# run Naming Service

echo "Starting Naming Service ..."

rm -f nsd.ior
nsd --ior nsd.ior &
nsd_pid=$!

trap "kill $nsd_pid > /dev/null 2> /dev/null" 0

# wait for Naming Service to start

for i in 0 1 2 3 4 5 6 7 8 9 ; do
	if test -r nsd.ior ; then break ; else sleep 1 ; fi
done

# start Server

echo "Starting Component Server ..."

./server -ORBInitRef NameService=file://`pwd`/nsd.ior &
server_pid=$!

trap "kill $nsd_pid $server_pid > /dev/null 2> /dev/null" 0

# give server some time to start

sleep 3

# run Client

echo "Running Client ..."

./client -ORBInitRef NameService=file://`pwd`/nsd.ior

