bulk.sh 737 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. async="true"
  3. interval="0.1"
  4. if [ "$1" = "-s" ]; then
  5. async=""
  6. shift
  7. elif [ "$1" = "-i" ]; then
  8. interval="$2"
  9. shift 2
  10. fi
  11. host="$1"
  12. shift
  13. if [ -z "$host" ] || [ ! -z "$@" ]; then
  14. echo "Usage: $0 [-s | -i <interval>] <host uri>"
  15. exit 1
  16. fi
  17. # insert newline after uuids
  18. id_file="$(echo | cat 'uuids.txt' - 'usernames.txt')"
  19. mapfile ids <<< $id_file
  20. bulk() {
  21. trap return INT
  22. for id in $ids; do
  23. if [ -z "$async" ]; then
  24. curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?helm"
  25. else
  26. curl -sSL -o /dev/null -w "%{url_effective} %{http_code} %{time_total}s\\n" -- "$host/avatars/$id?helm" &
  27. sleep "$interval"
  28. fi
  29. done
  30. }
  31. time bulk