midwire
7/10/2014 - 2:02 PM

TOR service control script

TOR service control script

#!/usr/bin/env bash

cmd=$1

function start_tor() {
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.tor.plist
}

function stop_tor() {
  launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.tor.plist
}

case $cmd in
  start )
    start_tor
    ;;
  stop )
    stop_tor
    ;;
  restart )
    stop_tor
    start_tor
    ;;
  status )
    ps aux|grep '/usr/local/opt/tor/bin/tor'|grep -v 'grep'
    ;;
  * )
    echo "Usage: $0 [status, start, stop, restart]"
    ;;
esac