#! /bin/sh
#
# This script takes a list of hosts and starts the servers on those machines
# It can handle a "hosts" file as long as the entries are sorted.
if [ $1 = "-help" ] ; then 
    echo "$0 - start the p4server on the specified nodes"
    echo "$0 port hostfile"
    echo "The value of port should be passed to p4 jobs through with the"
    echo "-p4ssport # option."
    echo "This needs to be edited for different installations."
    echo "Also, it should NOT be run with an entire hostfile; rather, a "
    echo "subset of the hosts should be chosen."
    exit
fi

SERVERDIR="/usr/local/p4-1.2c/SUN/bin"
echo $1 $SERVERDIR | \
    awk '{if (NR == 1) {
             APORT = $1 ;
             SERVR = $2
             }
          else {
	     if (substr($1,1,1) != "#") {
                 if (V != $1) {
                     printf("rsh %s %s/serv_p4 -d -p %s &\n",$1,SERVR,APORT);
    		     printf("echo Starting p4server on %s\n",$1 )
                     }
	         V = $1
		 }
             }
          }' - $2 | /bin/sh



