2015-07-26 20:38:40 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# ######################################################################
|
|
|
|
# Start Tor and switch the system-wide proxy settings in OS X
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# Usage:
|
|
|
|
# just run tor.sh in Terminal, kill with ctrl + c
|
|
|
|
# ----------------------------------------------------------------------
|
2016-05-15 18:20:46 +02:00
|
|
|
# more info:
|
|
|
|
# https://kremalicious.com/simple-tor-setup-on-mac-os-x/
|
2015-07-26 20:38:40 +02:00
|
|
|
# ######################################################################
|
|
|
|
|
|
|
|
# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'
|
|
|
|
INTERFACE=Wi-Fi
|
|
|
|
|
|
|
|
# Ask for the administrator password upfront
|
|
|
|
sudo -v
|
|
|
|
|
|
|
|
# Keep-alive: update existing `sudo` time stamp until finished
|
|
|
|
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
|
|
|
|
2016-05-15 18:20:46 +02:00
|
|
|
# trap ctrl-c and call disable_proxy()
|
|
|
|
function disable_proxy() {
|
|
|
|
sudo networksetup -setsocksfirewallproxystate $INTERFACE off
|
2017-06-12 01:21:12 +02:00
|
|
|
echo "$(tput setaf 64)SOCKS proxy disabled.$(tput sgr0)"
|
2016-05-15 18:20:46 +02:00
|
|
|
}
|
|
|
|
trap disable_proxy INT
|
|
|
|
|
2015-07-26 20:38:40 +02:00
|
|
|
# Let's roll
|
|
|
|
sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off
|
|
|
|
sudo networksetup -setsocksfirewallproxystate $INTERFACE on
|
2016-05-15 18:20:46 +02:00
|
|
|
|
2017-06-12 01:21:12 +02:00
|
|
|
echo "$(tput setaf 64)SOCKS proxy 127.0.0.1:9050 enabled."
|
|
|
|
echo "$(tput setaf 136)Starting Tor...$(tput sgr0)"
|
2016-05-15 18:20:46 +02:00
|
|
|
|
2015-07-26 20:38:40 +02:00
|
|
|
tor
|