belarus.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/bash
  2. # Populate array of months we care about
  3. months=()
  4. # 2020
  5. for i in {7..12}; do
  6. months+=( 2020-$(printf %02d $i) )
  7. done
  8. # 2021
  9. for i in {1..4}; do
  10. months+=( 2021-$(printf %02d $i) )
  11. done
  12. cd belarus-2020-2021
  13. if [ "$1" == "--fast" ]; then
  14. echo "Repacking some pre-processed data for the next step..."
  15. ./scripts/repack-preprocessed-data.sh
  16. else
  17. echo "Downloading data from the Tor Project..."
  18. ./scripts/download-bridge-data.sh
  19. if [ "$1" == "-s" ]; then
  20. # Do this step sequentially
  21. for i in ${months[@]}; do
  22. if [ ! -e data/bridge-extra-infos-${i}_processed.tar.xz ]; then
  23. ./scripts/process-data-docker.sh "$i"
  24. fi
  25. done
  26. else
  27. # Do this step in parallel
  28. for i in ${months[@]}; do
  29. if [ ! -e data/bridge-extra-infos-${i}_processed.tar.xz ]; then
  30. ./scripts/process-data-docker.sh "$i" &
  31. fi
  32. done
  33. wait
  34. fi
  35. fi
  36. docker run --name "tp-belarus" --rm -d -i tp-analysis:latest || exit 1
  37. docker exec tp-belarus sh -c "mkdir -p /home/analysis/belarus-2020-2021/data/bridge_data"
  38. # Copy archives to docker
  39. for i in data/*_processed.tar.xz; do
  40. docker cp "${i}" tp-belarus:/home/analysis/belarus-2020-2021/data/bridge_data/
  41. done
  42. # Return to artifact root
  43. cd ..
  44. # Process the data
  45. docker exec tp-belarus sh -c "cd /home/analysis/belarus-2020-2021 && ./scripts/get-email-bridges.sh && ./scripts/clean-bridge-data.sh" && \
  46. docker exec tp-belarus sh -c "cd /home/analysis/belarus-2020-2021 && ./scripts/get-stats.sh" | tee section-3-results
  47. docker cp tp-belarus:/home/analysis/belarus-2020-2021/appendix-a-results.tex . && \
  48. docker cp tp-belarus:/home/analysis/belarus-2020-2021/appendix-a-results.pdf . && \
  49. docker stop tp-belarus