#!/bin/csh

# script to start the dd server on a given host
# from a remote host
# Executed by start_all_dd_servers
#
# CW Jan 2, 1996
#

if ( ($#argv != 3) && ($#argv != 2) ) then
	echo "wrong number of arguments"
	echo "usage: start_dd_server dd_top_directory dd_version dd_setup_file"
	exit(1)
endif

set DD_SERVER_LOGFILE = /tmp/dd_server.logfile
setenv LD_LIBRARY_PATH
source /home/timmer/cvs/coda_source/dd/.setup

if ( $#argv == 3 ) then
	if ( -e $argv[3] ) then
		setenv DDD_CONFIGURATION_FILE $argv[3]
#		echo "Distributed dd configuration file is $DDD_CONFIGURATION_FILE"
	endif
endif

# check whether the server logfile is present, if so 
# try to kill the process - this is a double check
if ( -e $DD_SERVER_LOGFILE ) then
	set info = `head -1 $DD_SERVER_LOGFILE`
	kill -9 $info[3]
	rm $DD_SERVER_LOGFILE
	echo "process killed"
endif

$dd_bin/dd_server >& /tmp/dd_server.logfile &
echo "server started"

