#!/bin/csh 

#
# stop all servers on the remote hosts if they are any
#
# Usage: stop_dd_servers dd_configuration_file
#
# CW Jan 4, 1996
#

#
# look for this file to find the server
set DD_SERVER_LOGFILE = /tmp/dd_server.logfile

#
# check the arguments 
#--------------------
if ( $#argv != 1 ) then
	echo "bad usage: "
	echo "use: stop_dd_servers dd_server_configuration_file"
	exit(1)
endif

if ( -e $argv[1] ) then
	echo "using configuration file $argv[1] \n"
else
	echo "configuration file NOT found "
	exit(1)
endif

set me = `whoami`

foreach i ("`cat $1`") 
	set info = `echo $i`
	if ( $info[1] == "#" ) then
		continue
	endif
	set log_info = `rsh $info[1] "head -1 $DD_SERVER_LOGFILE " `
	if ( $#log_info > 0 ) then
		echo "stopping dd_server pid $log_info[3] on $info[1]"
		rsh $info[1] "kill -9 $log_info[3]"
		rsh $info[1] "rm $DD_SERVER_LOGFILE"
	else
		echo "no server logfile found on $info[1]"
	endif	
end

