Last active
December 14, 2015 04:59
-
-
Save jippi/5032260 to your computer and use it in GitHub Desktop.
NB: This only works on OS X !! download raw; chmod +x unblock-us-netflix.sh; ./unblock-us-netflix.sh on | off
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Set up DNS configuration using resolver on OS X | |
| # | |
| # Requires one argument, the domain to point to unblock-us service | |
| # | |
| function setUp() { | |
| if [ -z "$1" ] | |
| then | |
| echo "setup :: missing first argument (domain)" | |
| exit 1 | |
| fi | |
| file="/etc/resolver/$1" | |
| if [ -e "$file" ] | |
| then | |
| echo "[OK] DNS config for $1 already exist" | |
| return 1 | |
| fi | |
| echo "nameserver 208.122.23.22" > "$file" | |
| echo "port 53" >> "$file" | |
| echo "[OK] DNS config for $1 was written successfully" | |
| return $? | |
| } | |
| # Tear down DNS configuration using resolver on OS X | |
| # | |
| # Requires one argument, the domain to un-"un-block" | |
| # | |
| function tearDown() { | |
| if [ -z "$1" ] | |
| then | |
| echo "tearDown :: missing first argument (domain)" | |
| exit 1 | |
| fi | |
| file="/etc/resolver/$1" | |
| if [ ! -e "$file" ] | |
| then | |
| echo "[OK] DNS change for $1 is not configured" | |
| return 1 | |
| fi | |
| rm $file | |
| echo "[OK] DNS config for $1 has been removed successfully" | |
| return $? | |
| } | |
| # Display help dialog and exit | |
| # | |
| function help() { | |
| echo "" | |
| echo "UnBlock-us OS X - netflix switcher" | |
| echo "" | |
| echo "$0 on" | |
| echo " Route netflix through UnBlock-US" | |
| echo "" | |
| echo "$0 off" | |
| echo " Don't route netflix through UnBlock-US" | |
| echo "" | |
| exit 1 | |
| } | |
| mode=$1 | |
| if [ -z "$mode" ] | |
| then | |
| help | |
| fi | |
| if [ $USER != "root" ] | |
| then | |
| echo "" | |
| echo "Error: this tool requires root"; | |
| echo "" | |
| help | |
| fi | |
| mkdir -p "/etc/resolver" | |
| if [ $mode = "on" ] | |
| then | |
| setUp "netflix.com" | |
| setUp "movies1.netflix.com" | |
| setUp "movies2.netflix.com" | |
| elif [ $mode = "off" ] | |
| then | |
| tearDown "netflix.com" | |
| tearDown "movies1.netflix.com" | |
| tearDown "movies2.netflix.com" | |
| else | |
| help | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment