| 
														
															@@ -1,20 +1,20 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 #!/bin/sh 
														 | 
														
														 | 
														
															 #!/bin/sh 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-# A script to turn tor sock4a in privoxy on or off. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+# A script to turn Tor SOCKS4a in Privoxy on or off. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-CONFFILE=/etc/privoxy/config		# privoxy config file. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-TOR_REG="forward.*localhost:9050"	# Regular expression open the tor in privoxy 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-PRIVOXY="/etc/init.d/privoxy restart"	# command to reload privoxy config file. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-SED="/bin/sed"				# sed command, of course. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-GREP="/bin/grep"			# grep command. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+CONFFILE=/etc/privoxy/config            # privoxy config file. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+TOR_REG="forward.*localhost:9050"       # Regular expression to find Tor in privoxy 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+PRIVOXY="/etc/init.d/privoxy restart"   # command to reload privoxy config file. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+SED="/bin/sed"                          # sed command, of course. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+GREP="/bin/grep"                        # grep command. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 usage () { 
														 | 
														
														 | 
														
															 usage () { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 echo "\ 
														 | 
														
														 | 
														
															 echo "\ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+privoxy-tor-toggle: Change Privoxy's configuration to use/not use Tor. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 Usage: 
														 | 
														
														 | 
														
															 Usage: 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   privoxy.tor 			<-- No arguments. Switch the tor on or off. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   privoxy.tor [on|off]		<-- Set the tor on or off. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   privoxy.tor !.*xia		<-- Any argument other than above shows 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-				    current status of the tor. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   privoxy.tor [-h|--help|-?]	<-- Print usage. 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   privoxy.tor                  <-- Switch Tor on or off. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   privoxy.tor [on|off]         <-- Set Tor on or off. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   privoxy.tor status           <-- Display Tor's current status. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   privoxy.tor [-h|--help|-?]   <-- Print usage. 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 " 
														 | 
														
														 | 
														
															 " 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -34,22 +34,22 @@ set_tor () { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    tor_gate=$1 
														 | 
														
														 | 
														
															    tor_gate=$1 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    get_status 
														 | 
														
														 | 
														
															    get_status 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    if [ $tor_status = $tor_gate ] ; then 
														 | 
														
														 | 
														
															    if [ $tor_status = $tor_gate ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      echo "The tor is already $1." 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      echo "Tor is already $1." 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       return 
														 | 
														
														 | 
														
															       return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    elif [ $tor_gate = flip ] ; then 
														 | 
														
														 | 
														
															    elif [ $tor_gate = flip ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	if [ $tor_status = on ] ; then 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-		tor_gate=off 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	elif [ $tor_status = off ] ; then 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     		tor_gate=on 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	fi 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if [ $tor_status = on ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                tor_gate=off 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        elif [ $tor_status = off ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                tor_gate=on 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    fi 
														 | 
														
														 | 
														
															    fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   echo "Turning the tor $tor_gate..." 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   echo "Turning Tor $tor_gate..." 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    if [ $tor_gate = on ] ; then 
														 | 
														
														 | 
														
															    if [ $tor_gate = on ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   	reg=s/^#\($TOR_REG\)/\\1/ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	$SED -i.bak -r "$reg"  $CONFFILE 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reg=s/^#\($TOR_REG\)/\\1/ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        $SED -i.bak -r "$reg"  $CONFFILE 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    else 
														 | 
														
														 | 
														
															    else 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   	reg=s/^\($TOR_REG\)/#\\1/ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-	$SED -i.bak -r "$reg" $CONFFILE 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reg=s/^\($TOR_REG\)/#\\1/ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        $SED -i.bak -r "$reg" $CONFFILE 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    fi 
														 | 
														
														 | 
														
															    fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    $PRIVOXY 
														 | 
														
														 | 
														
															    $PRIVOXY 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    return 0; 
														 | 
														
														 | 
														
															    return 0; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -59,13 +59,15 @@ if [ x$1 = x ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    set_tor flip 
														 | 
														
														 | 
														
															    set_tor flip 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 elif [ $1 = on ] ; then 
														 | 
														
														 | 
														
															 elif [ $1 = on ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    set_tor on 
														 | 
														
														 | 
														
															    set_tor on 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-elif [ $1 = off ] ; then  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+elif [ $1 = off ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    set_tor off 
														 | 
														
														 | 
														
															    set_tor off 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+elif [ $1 = status ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   get_status 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   echo "Tor is $tor_status" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 elif [ $1 = --help ] || [ $1 = -h ] || [ $1 = "-?" ] ; then 
														 | 
														
														 | 
														
															 elif [ $1 = --help ] || [ $1 = -h ] || [ $1 = "-?" ] ; then 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    usage 
														 | 
														
														 | 
														
															    usage 
														 | 
													
												
											
												
													
														| 
														 | 
														
															    exit 0 
														 | 
														
														 | 
														
															    exit 0 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 else 
														 | 
														
														 | 
														
															 else 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   get_status 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-   echo "Currently, the tor is $tor_status." 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+   echo "Unrecognized option: \"$1\"" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 fi 
														 | 
														
														 | 
														
															 fi 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |