get-bridge-data.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. parallel=false
  3. if [ "$1" == "-p" ]; then
  4. parallel=true
  5. fi
  6. # Populate array of months we care about
  7. months=()
  8. # 2020
  9. for i in $(seq 7 12); do
  10. months+=( 2020-$(printf %02d $i) )
  11. done
  12. # 2021
  13. for i in $(seq 1 4); do
  14. months+=( 2021-$(printf %02d $i) )
  15. done
  16. # Download the archives if we don't have them already
  17. for i in ${months[@]}; do
  18. if [ ! -f data/bridge-extra-infos-${i}.tar.xz ]; then
  19. curl -Lo data/bridge-extra-infos-${i}.tar.xz https://collector.torproject.org/archive/bridge-descriptors/extra-infos/bridge-extra-infos-${i}.tar.xz || exit 1
  20. fi
  21. done
  22. # Check that we have the right archives
  23. sha256sum -c data/bridge-extra-infos.sha256 || exit 1
  24. # Extract the data for each month
  25. if [ "$parallel" == "true" ]; then
  26. # Do it in parallel
  27. for i in ${months[@]}; do
  28. ./scripts/extract-extra-infos-archive.sh bridge-extra-infos-${i}.tar.xz &
  29. done
  30. # Wait until we're done extracting everything
  31. wait
  32. else
  33. for i in ${months[@]}; do
  34. ./scripts/extract-extra-infos-archive.sh bridge-extra-infos-${i}.tar.xz
  35. done
  36. fi