undo_telemetry.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. # shellcheck disable=SC1091,SC2016
  3. set -ex
  4. # list of urls to match:
  5. # - mobile.events.data.microsoft.com
  6. # - vortex.data.microsoft.com
  7. SEARCH="\.data\.microsoft\.com"
  8. REPLACEMENT="s|//[^/]+\.data\.microsoft\.com|//0\.0\.0\.0|g"
  9. # include common functions
  10. . ../utils.sh
  11. if is_gnu_sed; then
  12. replace_with_debug () {
  13. echo "found: ${2}"
  14. sed -i -E "${1}" "${2}"
  15. }
  16. else
  17. replace_with_debug () {
  18. echo "found: ${2}"
  19. sed -i '' -E "${1}" "${2}"
  20. }
  21. fi
  22. export -f replace_with_debug
  23. d1=$( date +%s )
  24. if [[ "${OS_NAME}" == "linux" ]]; then
  25. if [[ ${VSCODE_ARCH} == "x64" ]]; then
  26. ./node_modules/@vscode/ripgrep/bin/rg --no-ignore -l "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
  27. else
  28. grep -rl --exclude-dir=.git -E "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
  29. fi
  30. elif [[ "${OS_NAME}" == "osx" ]]; then
  31. ./node_modules/@vscode/ripgrep/bin/rg --no-ignore -l "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
  32. else
  33. ./node_modules/@vscode/ripgrep/bin/rg --no-ignore --path-separator=// -l "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
  34. fi
  35. d2=$( date +%s )
  36. echo "undo_telemetry: $((d2 - d1))s"