summaryrefslogtreecommitdiffstats
path: root/scripts/listen-handshake.sh
blob: 7ce55c6048092b772c2125769d25c49d93ea51b7 (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
36
37
38
39
#!/bin/bash

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

NC="/opt/ivysync/bin/netcat"
# check if it is openbsd netcat
NC_ver="`$NC -h 2>&1|head -n 1 | awk '{print $1}'`"
if [ "$NC_ver" = "OpenBSD" ]; then
	echo "using OpenBSD version of netcat"
	NC="$NC -q 0"
elif [ "$NC_ver" = "GNU" ]; then
	echo "using GNU version of netcat"
	NC="$NC -c"
else
	echo "error: your version of netcat is not compatible"
	echo "please install an OpenBSD or GNU netcat implementation"
	echo "found on this system: `netcat -h 2>&1|head -n1`"
	exit 1
fi

# some more version might be around that is not supported..

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

echo "listening on $IFACE configured with address $IP ..."
master="`echo | $NC -u -l -p 3332`"

echo "contacted by master $master"
echo "$IP" | netcat -u $master 3331

echo "master replied"


exit 0