undo_telemetry.sh 1.2 KB

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