#!/bin/sh
# http://www.berklix.com/~jhs/bin/.sh/ping_gates
# ~/bin/.sh/ping_gates	by jhs@ 

if [ "X`ping -c 1 mart | grep packets`" = "X`ping -c 1 park | grep packets`" ]; 
	then 	
	echo -n "Both gate hosts mart and park are up, "
	echo    "on one host you may need to type:"
	echo "	xs ifconfig xl0 -alias 192.168.0.10"

bla=~/tmp/`basename $0`
	echo "Seeing if mart xl0 has 192.168.91.10:"
	rsh mart ifconfig xl0 | grep 192.168.91.10 > $bla.mart
	cat $bla.mart
	echo "Seeing if park xl0 has 192.168.91.10:"
	rsh park ifconfig xl0 | grep 192.168.91.10 > $bla.park
	cat $bla.park

	echo "Seeing if hosts compete for packets to 192.168.91.10"
	if [ "X`cat $bla.mart`" = "X`cat $bla.park`" ];
		then
		echo "Hosts compete for packets to 192.168.91.10,"
		echo "on one host you must type:"
		echo "	xs ifconfig xl0 -alias 192.168.0.10"
	else
		echo "OK, no competition for packets, nothing to fix"
	fi
else
	echo "OK, Only one gate host is up"
fi
rm $bla.mart $bla.park
