ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
+ip=$(ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_get_ip")
+
# make torrent file
-ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_create_torrent"
-ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_create_torrent"
+ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_create_torrent $ip"
+ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_create_torrent $ip"
# start tracker
ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_run_tracker"
-ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_run_tracker"
sleep 5
# start seeder
-ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_client_seeder"
+ssh -n -f -p $port1 -l p2p $host1 "/home/p2p/eurocon/local_start_seeder"
# start leecher
-ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_client_leecher"
+ssh -n -f -p $port2 -l p2p $host2 "/home/p2p/eurocon/local_start_leecher"
# wait for it
sleep 15
sleep 45
+# cleanup
+ssh -n -f -p $port1 -l root $host1 "/home/p2p/eurocon/local_clean"
+ssh -n -f -p $port2 -l root $host2 "/home/p2p/eurocon/local_clean"
+
# sync back
-rsync -avz -e "ssh -p $port1" p2p@$host1:/home/p2p/eurocon/hrk.log $host1-$id-seeder.log
-rsync -avz -e "ssh -p $port2" p2p@$host2:/home/p2p/eurocon/hrk.log $host2-$id-leecher.log
+rsync -avz -e "ssh -p $port1" p2p@$host1:/home/p2p/eurocon/hrk.log ../eurocon-log/$host1-$port1-$id-$timeout-seeder.log
+rsync -avz -e "ssh -p $port2" p2p@$host2:/home/p2p/eurocon/hrk.log ../eurocon-log/$host2-$port2-$id-$timeout-leecher.log
+
+# backup logs
+ssh -n -f -p $port1 -l p2p $host1 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"
+ssh -n -f -p $port2 -l p2p $host2 "mv /home/p2p/eurocon/hrk.log hrk-$(date +%s).log"