1
0
mirror of https://github.com/kremalicious/dotfiles.git synced 2024-11-25 03:20:09 +01:00
dotfiles/bin/tor.sh

27 lines
987 B
Bash
Executable File

#!/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
# ----------------------------------------------------------------------
# loosely based on
# http://leonid.shevtsov.me/en/an-easy-way-to-use-tor-on-os-x
# ######################################################################
# '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 &
# Let's roll
sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off
sudo networksetup -setsocksfirewallproxystate $INTERFACE on
tor
sudo networksetup -setsocksfirewallproxystate $INTERFACE off