#!/bin/bash
ip_addr=`ifconfig | grep "inet" | awk -F " " {'print $2'} | sed -n '1p'`
for i in "tor" "proxychains" "privoxy"
do
which $i 2>&1 >/dev/null
if [ $? -ne 0 ];then
echo "please wait moment.....,come soon\n"
apt-get install $i -y >/dev/null 2>&1
if [ $? -eq 0 ];then
echo "$i installed....ok!\n"
else
echo "$i install failed! please check you network!...... \n"
exit 1
fi
else
/etc/init.d/tor stop >/dev/null 2>&1
killall privoxy >/dev/null 2>&1
echo "$i installed ready ....ok\n"
fi
done
proxychains_config="/etc/proxychains.conf"
> $proxychains_config
echo "random_chain" >> $proxychains_config
echo "chain_len = 1" >> $proxychains_config
echo "proxy_dns" >> $proxychains_config
echo "tcp_read_time_out 15000" >> $proxychains_config
echo "tcp_connect_time_out 8000" >> $proxychains_config
echo "[ProxyList]" >> $proxychains_config
echo "socks4 $ip_addr 9050" >> $proxychains_config
if [ $? -eq 0 ] ;then
echo "proxychains config succeed ! \n"
else
echo "proxychains config failed ! please check.....\n"
exit 1
fi
privoxy_config="/etc/privoxy/config"
sed -i "s#127.0.0.1:8118#$ip_addr:8118#g" $privoxy_config
echo "forward-socks5 / $ip_addr:9050 ." >> $privoxy_config
if [ $? -eq 0 ] ;then
echo "privoxy config succeed\n"
else
echo "privoxy config failed ! please check....\n"
exit 1
fi
/etc/init.d/tor start >/dev/null 2>&1
if [ $? -eq 0 ] ;then
echo "Tor start succeed ....ok\n"
else
echo "Tor start failed,please use 'journalctl -xe' check,thank you....failed\n"
exit 1
fi
/usr/sbin/privoxy /etc/privoxy/config >/dev/null 2>&1
if [ $? -eq 0 ] ;then
echo "Privoxy start succeed .....ok\n"
else
echo "Privoxy start failed,please use 'journalctl -xe' check,thank you....failed\n"
exit 1
fi
echo "please Ctrl+C to stop !\n"
while true
do
sleep 45s
/etc/init.d/tor restart >/dev/null 2>&1
if [ $? -eq 0 ] ;then
echo "Tor restart succeed! \n"
else
echo "\n\033[33m Tor restart failed !\033[0m\n"
exit 1
fi
done