#!/bin/sh
-. ./testlib.sh
+. "${0%/*}/testlib.sh"
+
+echo Initializing node...
# Initialize server node
init foo
set DeviceType dummy
set Port 32759
-set Address localhost
+set Address 127.0.0.1
add Subnet 10.0.0.1
add Subnet fec0::/64
EOF
# Set up scripts
+echo Setting up scripts...
+
OUT=$d1/scripts.out
rm -f $OUT
echo $script \$NETNAME,\$NAME,\$DEVICE,\$IFACE,\$NODE,\$REMOTEADDRESS,\$REMOTEPORT,\$SUBNET,\$WEIGHT,\$INVITATION_FILE,\$INVITATION_URL,\$DEBUG >>$OUT
EOF
chmod u+x $d1/$script
+
+cat >$d1/$script.cmd << EOF
+echo $script %NETNAME%,%NAME%,%DEVICE%,%IFACE%,%NODE%,%REMOTEADDRESS%,%REMOTEPORT%,%SUBNET%,%WEIGHT%,%INVITATION_FILE%,%INVITATION_URL%,%DEBUG% >>$OUT
+EOF
done
# Start server node
-$tinc -n netname $c1 start $r1
+echo Starting server node...
+
+$tinc $c1 -n netname start $r1
echo foo-started >>$OUT
# Invite client node
-url=`$tinc -n netname2 $c1 invite bar`
+echo Inviting client node...
+
+url=`$tinc $c1 -n netname2 invite bar | sed 's/\r//'`
file=`cd $d1/invitations; ls | grep -v ed25519_key.priv`
echo bar-invited >>$OUT
-$tinc -n netname3 $c2 join $url
+
+echo Joining client node...
+
+$tinc $c2 -n netname3 join $url
echo bar-joined >>$OUT
# Start and stop client node
+echo Starting client node...
+
$tinc $c2 << EOF
set DeviceType dummy
set Port 32760
# Stop server node
$tinc $c1 stop
+sleep 1
+$tinc $c2 stop
# Check if the script output is what is expected
tinc-down netname,foo,dummy,,,,,,,,,5
EOF
+sed -i 's/\r//' $OUT
cmp $OUT $OUT.expected