Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.84 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # cfgames.sh
  4. #
  5. # This is a shell script that allows you to watch the CrossFit games from
  6. # games.crossfit.com within the US, instead of being routed through ESPN3.
  7. # It just fakes the Javascript library called by the stream to respond that
  8. # you are outside of the US, and will clean up after itself once you're
  9. # done.
  10. #
  11. # Requirements: root privileges (mucking around in /etc and running a server
  12. # on port 80), Python >= 2.6 (may work with any 2.x but I'm not sure).
  13. #
  14. # It was written on an OS X machine: if you name it .command instead of
  15. # .sh and mark it executable, you can actually just double-click the script
  16. # in Finder to run it. On non-BSD-based systems, I don't remember if the
  17. # hosts file is the same, so adjust as needed.
  18.  
  19. FOLDER=cfgames_locationfake
  20.  
  21. # Ensure we're able to use sudo, since we need to edit /etc/hosts
  22. amiroot=$(sudo whoami)
  23. if [ "$amiroot" != "root" ]; then
  24.     echo "You must have sudo permission to run this script."
  25.     exit 1
  26. fi
  27.  
  28. # Point to ourselves instead of j.maxmind.com
  29. echo "*** Backing up & modifying hosts file"
  30. sudo cp /etc/hosts /etc/hosts.backup
  31. cp /etc/hosts ./hosts
  32. echo "127.0.0.1 j.maxmind.com" >> ./hosts
  33. sudo mv ./hosts /etc/hosts
  34.  
  35. # Create the geolocation faking Javascript file
  36. echo "*** Creating geolocation fake script"
  37. mkdir "$FOLDER"
  38. cd "$FOLDER"
  39. mkdir app
  40. cd app
  41. echo "function geoip_country_code() { return 'non-US'; }" >> country.js
  42. echo "function geoip_country_name() { return 'non-United States'; }" >> country.js
  43. cd ..
  44.  
  45. # Load up a webserver, don't care about output
  46. echo "*** Loading server. Use ^C to exit"
  47. sudo python -m SimpleHTTPServer 80 > /dev/null
  48.  
  49. # Once the user has ^C'd out, clean up
  50. # The user may need to re-enter their password
  51. echo "*** Cleaning up"
  52. cd ..
  53. rm -rf "$FOLDER"
  54. sudo rm /etc/hosts
  55. sudo mv /etc/hosts.backup /etc/hosts
  56.  
  57. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement