test-signal-socket: new version of eurocon scripts
[p2p-testing-infrastructure.git] / Utils / test-socket-signal / test / eurocon / remote_run_if
1 #!/bin/bash
2
3 if test $# -ne 6; then
4         echo "Usage: $0 host1 port1 host2 port2 timeout id" 1>&2
5         exit 1
6 fi
7
8 host1=$1
9 port1=$2
10 host2=$3
11 port2=$4
12 timeout=$5
13 _id=$6
14
15 # cleanup
16 ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
17 ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
18
19 ip=$(ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_get_ip")
20
21 # make torrent file
22 ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_create_torrent $ip"
23 ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_create_torrent $ip"
24
25 # start tracker
26 ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_run_tracker"
27
28 sleep 5
29
30 # start seeder
31 ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_start_seeder"
32
33 # start leecher
34 ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_start_leecher"
35
36 # wait for it
37 sleep 15
38
39 # put leecher interface down
40 ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_ifdown"
41
42 # sleep as planned
43 sleep $timeout
44
45 # put interface up
46 ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_ifup"
47
48 sleep 45
49
50 # cleanup
51 ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
52 ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
53
54 # sync back
55 rsync -avz -e "ssh -p $port1" p2p@$host1:/home/p2p/eurocon/hrk.log ../eurocon-log/$host1-$port1-$id-$timeout-seeder.log
56 rsync -avz -e "ssh -p $port2" p2p@$host2:/home/p2p/eurocon/hrk.log ../eurocon-log/$host2-$port2-$id-$timeout-leecher.log
57
58 # backup logs
59 ssh -n -f -p $port1 -l p2p $host1 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"
60 ssh -n -f -p $port2 -l p2p $host2 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"