summaryrefslogtreecommitdiffstats
path: root/scripts/offer_handshake.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/offer_handshake.sh')
-rwxr-xr-xscripts/offer_handshake.sh26
1 files changed, 22 insertions, 4 deletions
diff --git a/scripts/offer_handshake.sh b/scripts/offer_handshake.sh
index 54950c7..1564a76 100755
--- a/scripts/offer_handshake.sh
+++ b/scripts/offer_handshake.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# here configure the file with the list of IP or hostnames, one per line
-LISTFILE=list
+LISTFILE=/root/list
if [ -z $1 ]; then
echo "usage: $0 network_interface"
@@ -12,6 +12,25 @@ IFACE="$1"
IP="`ifconfig $IFACE | grep 'inet addr'| awk '{print $2}'|cut -f2 -d:`"
+
+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
+
+
+
ready=false
for i in `cat $LISTFILE`; do
@@ -19,12 +38,12 @@ for i in `cat $LISTFILE`; do
echo -n "handshaking $i"
# background listener
- (answer=`echo | nc -q 0 -u -l 3331`;
+ (answer=`echo | $NC -u -l -p 3331`;
echo $answer > /tmp/handshake.$i.ok) &
while ! [ -r /tmp/handshake.$i.ok ]; do
sleep 1
- ../udpbroadcast $i 3332 $IP 1>&2 > /dev/null
+ udpbroadcast $i 3332 $IP 1>&2 > /dev/null
echo -n "."
done
echo -n " answer: `cat /tmp/handshake.$i.ok`"
@@ -32,4 +51,3 @@ for i in `cat $LISTFILE`; do
echo
done
-exit 0