Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # cfgames.sh
- #
- # This is a shell script that allows you to watch the CrossFit games from
- # games.crossfit.com within the US, instead of being routed through ESPN3.
- # It just fakes the Javascript library called by the stream to respond that
- # you are outside of the US, and will clean up after itself once you're
- # done.
- #
- # Requirements: root privileges (mucking around in /etc and running a server
- # on port 80), Python >= 2.6 (may work with any 2.x but I'm not sure).
- #
- # It was written on an OS X machine: if you name it .command instead of
- # .sh and mark it executable, you can actually just double-click the script
- # in Finder to run it. On non-BSD-based systems, I don't remember if the
- # hosts file is the same, so adjust as needed.
- FOLDER=cfgames_locationfake
- # Ensure we're able to use sudo, since we need to edit /etc/hosts
- amiroot=$(sudo whoami)
- if [ "$amiroot" != "root" ]; then
- echo "You must have sudo permission to run this script."
- exit 1
- fi
- # Point to ourselves instead of j.maxmind.com
- echo "*** Backing up & modifying hosts file"
- sudo cp /etc/hosts /etc/hosts.backup
- cp /etc/hosts ./hosts
- echo "127.0.0.1 j.maxmind.com" >> ./hosts
- sudo mv ./hosts /etc/hosts
- # Create the geolocation faking Javascript file
- echo "*** Creating geolocation fake script"
- mkdir "$FOLDER"
- cd "$FOLDER"
- mkdir app
- cd app
- echo "function geoip_country_code() { return 'non-US'; }" >> country.js
- echo "function geoip_country_name() { return 'non-United States'; }" >> country.js
- cd ..
- # Load up a webserver, don't care about output
- echo "*** Loading server. Use ^C to exit"
- sudo python -m SimpleHTTPServer 80 > /dev/null
- # Once the user has ^C'd out, clean up
- # The user may need to re-enter their password
- echo "*** Cleaning up"
- cd ..
- rm -rf "$FOLDER"
- sudo rm /etc/hosts
- sudo mv /etc/hosts.backup /etc/hosts
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement