#! /bin/sh

# This script assumes that all hosts that run the node managers and system
# managers share a common filesystem. If this is not the case, run setup
# for each separately.

# Edit next line. Path name of the top of the PRM directory hierarchy. 
PRM_TOP=/nfs/pfs/divirs/jmsm/new

# Edit next line. Put in the name of the Host on which system manager runs.
SMHOSTS="zephyr.isi.edu"

# Next line contains the name of the file in which node names are specified.
# Node names are internet-style host names. All host names are specified on a
# single line, separated by spaces.
NODESFILE=nls

# ping used to find out whether a host is on the network.
PING=/usr/etc/ping
RSH=/usr/ucb/rsh

BINDIR=$PRM_TOP/bin

# Directories in which nodemngr and sysmngr binaries reside. At execution time
# the $ARCH gets appended to this.
NMGRDIR=$BINDIR    
SMGRDIR=$BINDIR    

# set -x

usage="Usage: PRM_kill config_file"

if [ $# -ne 1 ] ; then
	echo $usage
	exit 1
fi

if [ $ARCH = hp700 ] ; then
   RSH=/usr/bin/remsh
fi

read hostname mgr pid others < $1
while [ $hostname ] ; do
	$RSH $hostname " kill $pid  ; rm -f /tmp/nodemngr* /tmp/sysmngr* " \
	               > /dev/null 2>&1
	echo $others > .tmp_config
	read hostname mgr pid others < .tmp_config
done

rm -f $1  .tmp_config 