update shadowsocks version to 2.9.0

This commit is contained in:
Teddysun 2016-08-18 22:56:58 +09:00
parent a4a721536e
commit 89d876303b

View File

@ -19,6 +19,14 @@ echo "# Thanks: @clowwindy <https://twitter.com/clowwindy> #"
echo "#############################################################" echo "#############################################################"
echo echo
#Current folder
cur_dir=`pwd`
# Get public IP address
IP=$(ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1)
if [[ "$IP" = "" ]]; then
IP=$(wget -qO- -t1 -T2 ipv4.icanhazip.com)
fi
# Make sure only root can run our script # Make sure only root can run our script
function rootness(){ function rootness(){
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -74,7 +82,7 @@ fi
function pre_install(){ function pre_install(){
# Not support CentOS 5 # Not support CentOS 5
if centosversion 5; then if centosversion 5; then
echo "Not support CentOS 5, please change to CentOS 6+ or Debian 7+ or Ubuntu 12+ and try again." echo "Not supported CentOS 5, please change to CentOS 6+ or Debian 7+ or Ubuntu 12+ and try again."
exit 1 exit 1
fi fi
# Set shadowsocks config password # Set shadowsocks config password
@ -126,25 +134,25 @@ function pre_install(){
yum install -y automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel which yum install -y automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel which
else else
apt-get -y update apt-get -y update
apt-get -y install python python-dev python-pip python-setuptools curl wget unzip gcc swig automake make perl cpio apt-get -y install python python-dev python-pip python-setuptools python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential
fi fi
# Get IP address
echo "Getting Public IP address, Please wait a moment..."
IP=$(curl -s -4 icanhazip.com)
if [[ "$IP" = "" ]]; then
IP=$(curl -s -4 ipinfo.io/ip)
fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
echo
#Current folder
cur_dir=`pwd`
cd $cur_dir cd $cur_dir
} }
# Download files # Download files
function download_files(){ function download_files(){
# Download libsodium file
if ! wget --no-check-certificate -O libsodium-1.0.11.tar.gz https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz; then
echo "Failed to download libsodium file!"
exit 1
fi
# Download Shadowsocks file
if ! wget --no-check-certificate -O shadowsocks-master.zip https://github.com/shadowsocks/shadowsocks/archive/master.zip; then
echo "Failed to download Shadowsocks file!"
exit 1
fi
# Download ShadowsocksR chkconfig file
if [ "$OS" == 'CentOS' ]; then if [ "$OS" == 'CentOS' ]; then
# Download shadowsocks chkconfig file
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks -O /etc/init.d/shadowsocks; then if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks -O /etc/init.d/shadowsocks; then
echo "Failed to download shadowsocks chkconfig file!" echo "Failed to download shadowsocks chkconfig file!"
exit 1 exit 1
@ -214,29 +222,23 @@ function firewall_set(){
# Install Shadowsocks # Install Shadowsocks
function install_ss(){ function install_ss(){
which pip > /dev/null 2>&1 # Install libsodium
if [ $? -ne 0 ]; then tar zxf libsodium-1.0.11.tar.gz
if [ "$OS" == 'CentOS' ]; then cd $cur_dir/libsodium-1.0.11
which easy_install > /dev/null 2>&1 ./configure && make && make install
if [ $? -eq 0 ]; then echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
easy_install pip ldconfig
else # Install Shadowsocks
echo "easy_install command not found. please check it and try again." cd $cur_dir
unzip -q shadowsocks-master.zip
if [ $? -ne 0 ];then
echo "unzip shadowsocks-master.zip failed! Please check unzip command."
exit 1 exit 1
fi fi
fi
fi
if [ -f /usr/bin/pip ]; then cd $cur_dir/shadowsocks-master
if centosversion 6; then python setup.py install --record /usr/local/shadowsocks_install.log
# Fix swig failed error by install old version
pip install M2Crypto==0.22.3
else
pip install M2Crypto
fi
pip install greenlet
pip install gevent
pip install shadowsocks
if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then if [ -f /usr/bin/ssserver ] || [ -f /usr/local/bin/ssserver ]; then
chmod +x /etc/init.d/shadowsocks chmod +x /etc/init.d/shadowsocks
# Add run on system start up # Add run on system start up
@ -251,6 +253,7 @@ function install_ss(){
else else
echo echo
echo "Shadowsocks install failed! Please visit https://teddysun.com/342.html and contact." echo "Shadowsocks install failed! Please visit https://teddysun.com/342.html and contact."
install_cleanup
exit 1 exit 1
fi fi
clear clear
@ -266,12 +269,15 @@ function install_ss(){
echo "Welcome to visit:https://teddysun.com/342.html" echo "Welcome to visit:https://teddysun.com/342.html"
echo "Enjoy it!" echo "Enjoy it!"
echo echo
exit 0 }
else
echo # Install cleanup
echo "pip install failed! Please visit https://teddysun.com/342.html and contact." function install_cleanup(){
exit 1 cd $cur_dir
fi rm -f shadowsocks-master.zip
rm -rf shadowsocks-master
rm -f libsodium-1.0.11.tar.gz
rm -rf libsodium-1.0.11
} }
# Uninstall Shadowsocks # Uninstall Shadowsocks
@ -297,12 +303,10 @@ function uninstall_shadowsocks(){
rm -f /etc/shadowsocks.json rm -f /etc/shadowsocks.json
rm -f /var/run/shadowsocks.pid rm -f /var/run/shadowsocks.pid
rm -f /etc/init.d/shadowsocks rm -f /etc/init.d/shadowsocks
pip uninstall -y shadowsocks if [ -f /usr/local/shadowsocks_install.log ]; then
if [ $? -eq 0 ]; then cat /usr/local/shadowsocks_install.log | xargs rm -rf
echo "Shadowsocks uninstall success!"
else
echo "Shadowsocks uninstall failed!"
fi fi
echo "Shadowsocks uninstall success!"
else else
echo "uninstall cancelled, Nothing to do" echo "uninstall cancelled, Nothing to do"
fi fi
@ -320,6 +324,7 @@ function install_shadowsocks(){
firewall_set firewall_set
fi fi
install_ss install_ss
install_cleanup
} }
# Initialization step # Initialization step