run-container.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. img="troll-patrol"
  3. exp_num="$1"
  4. uuid="$2"
  5. container=$(docker run --rm -d -i $img)
  6. # Create results directory if it doesn't already exist
  7. mkdir -p results/${exp_num}
  8. docker cp configs/${uuid}/troll_patrol_config.json $container:/home/user/troll-patrol/
  9. cat configs/troll_patrol_config.json >> "results/${exp_num}/${uuid}"-troll_patrol_config.json
  10. docker cp configs/${uuid}/simulation_config.json $container:/home/user/simulation/
  11. cat configs/simulation_config.json >> "results/${exp_num}/${uuid}"-simulation_config.json
  12. # Run rdsys to give bridges to LA
  13. docker exec $container sh \
  14. -c "cd /home/user/rdsys/ && /usr/bin/time -v ./rdsys -config conf/config.json" \
  15. 2>&1 | grep -P '\t' > "results/${exp_num}/${uuid}"-rdsys &
  16. # Give rdsys time to start up
  17. sleep 5
  18. # Run LA, filtering a lot of the output because we don't need it
  19. docker exec $container sh \
  20. -c "cd /home/user/lox-distributor/ && ./lox-distributor" \
  21. | grep -v BridgeLine \
  22. | grep -v "Added bridge with fingerprint" \
  23. | grep -v "Today's date according to server" \
  24. &> "results/${exp_num}/${uuid}"-lox-distributor &
  25. # Give LA time to start up
  26. sleep 5
  27. # Run Troll Patrol
  28. docker exec $container sh \
  29. -c "cd /home/user/troll-patrol/ && ./troll-patrol --config troll_patrol_config.json" \
  30. &> "results/${exp_num}/${uuid}"-troll-patrol &
  31. # Give Troll Patrol time to start up
  32. sleep 5
  33. # Run simulation and then kill other processes
  34. docker exec $container sh \
  35. -c "cd /home/user/simulation/ && ./simulation && killall -s INT rdsys lox-distributor troll-patrol" \
  36. | tee "results/${exp_num}/${uuid}"-simulation 2>&1
  37. # Stop the container once it's done
  38. echo "Stopping docker container... It should be removed."
  39. docker stop $container