summaryrefslogtreecommitdiffstats
path: root/scripts/offer_handshake.sh
blob: 54950c7afdebb2fb6fe31d7af771eedf7e9d478f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash

# here configure the file with the list of IP or hostnames, one per line
LISTFILE=list

if [ -z $1 ]; then
        echo "usage: $0 network_interface"
        echo "example: $0 eth0"
        exit 1
fi
IFACE="$1"

IP="`ifconfig $IFACE | grep 'inet addr'| awk '{print $2}'|cut -f2 -d:`"

ready=false

for i in `cat $LISTFILE`; do
	rm -f /tmp/handshake.$i.ok
	echo -n "handshaking $i"

	# background listener
	(answer=`echo | nc -q 0 -u -l 3331`;
	 echo $answer > /tmp/handshake.$i.ok) &

	while ! [ -r /tmp/handshake.$i.ok ]; do
		sleep 1
		../udpbroadcast $i 3332 $IP 1>&2 > /dev/null
		echo -n "."
	done	
	echo -n " answer: `cat /tmp/handshake.$i.ok`"
	rm /tmp/handshake.$i.ok
	echo
done 

exit 0