2 # A script to turn Tor SOCKS4a in Privoxy on or off.
4 CONFFILE
=/etc
/privoxy
/config
# privoxy config file.
5 TOR_REG
="forward.*localhost:9050" # Regular expression to find Tor in privoxy
6 PRIVOXY
="/etc/init.d/privoxy restart" # command to reload privoxy config file.
7 SED
="/bin/sed" # sed command, of course.
8 GREP
="/bin/grep" # grep command.
12 privoxy-tor-toggle: Change Privoxy's configuration to use/not use Tor.
14 privoxy.tor <-- Switch Tor on or off.
15 privoxy.tor [on|off] <-- Set Tor on or off.
16 privoxy.tor status <-- Display Tor's current status.
17 privoxy.tor [-h|--help|-?] <-- Print usage.
21 # Find out the current status of tor. Set $tor_status
23 gret
=`$GREP -l -e "^$TOR_REG" $CONFFILE`
24 if [ x
$gret = x
] ; then
32 # Turn tor on/off according to $1
36 if [ $tor_status = $tor_gate ] ; then
37 echo "Tor is already $1."
39 elif [ $tor_gate = flip
] ; then
40 if [ $tor_status = on
] ; then
42 elif [ $tor_status = off
] ; then
46 echo "Turning Tor $tor_gate..."
47 if [ $tor_gate = on
] ; then
48 reg
=s
/^
#\($TOR_REG\)/\\1/
49 $SED -i.bak
-r "$reg" $CONFFILE
51 reg
=s
/^\
($TOR_REG\
)/#\\1/
52 $SED -i.bak
-r "$reg" $CONFFILE
60 elif [ $1 = on
] ; then
62 elif [ $1 = off
] ; then
64 elif [ $1 = status
] ; then
66 echo "Tor is $tor_status"
67 elif [ $1 = --help ] ||
[ $1 = -h ] ||
[ $1 = "-?" ] ; then
71 echo "Unrecognized option: \"$1\""