Skip to content

Instantly share code, notes, and snippets.

@h0rs3r4dish
Created July 27, 2013 18:10
Show Gist options
  • Save h0rs3r4dish/6095744 to your computer and use it in GitHub Desktop.
Save h0rs3r4dish/6095744 to your computer and use it in GitHub Desktop.
Quick workaround for the CrossFit Games stream geolocation blocking. For some reason, the Games site just loads some JS from an external provider, so we just inject our own non-US result there via a Python webserver.
#!/bin/sh
FOLDER=cfgames_locationfake
# Ensure we're able to use sudo
amiroot=$(sudo whoami)
if [ "$amiroot" != "root" ]; then
echo "You must have sudo permission to run this script."
exit 1
fi
# Point to ourselves
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 script
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
echo "*** Loading server. Use ^C to exit"
sudo python -m SimpleHTTPServer 80
# Once the user has stopped the server, clean up
echo "*** Cleaning up"
cd ..
rm -rf "$FOLDER"
sudo rm /etc/hosts
sudo mv /etc/hosts.backup /etc/hosts
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment