|
#! /bin/bash
Path=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
Export PATH
Clear
echo "#############################################################"
echo "# Install Shadowsocks (Python) for centos5.x (32bit/64bit) or centos6.x (32bit/64bit)"
echo "#"
echo "# Author:teddysun <i@teddysun.com>"
echo "#"
echo "#############################################################"
echo ""
# Get IP Addresses
ip= ' Ifconfig | grep ' inet addr: ' | Grep-v ' 127.0.0.* ' | Cut-d:-f2 | awk ' {print '} ';
# Install Shadowsocks
function Install_shadowsocks () {
Rootness
Disable_selinux
Pre_install
Download_files
Config_shadowsocks
Iptables_set
Install
}
# Make sure only root can run our script
function rootness () {
if [[$EUID-ne 0]]; Then
echo "Error:this script must be run as root!" 1>&2
Exit 1
Fi
}
# Disable SELinux
function Disable_selinux () {
If [-s/etc/selinux/config] && grep ' selinux=enforcing '/etc/selinux/config; Then
Sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config
Setenforce 0
Fi
}
# Pre-installation Settings
function Pre_install () {
#Set shadowsocks config password
echo "Please input password for shadowsocks:"
Read-p "(Default password:teddysun.com):" Shadowsockspwd
If ["$shadowsockspwd" = ""]; Then
Shadowsockspwd= "Teddysun.com"
Fi
echo "Password: $shadowsockspwd"
echo "####################################"
Get_char () {
Savedstty= ' Stty-g '
Stty-echo
Stty Cbreak
DD If=/dev/tty Bs=1 count=1 2>/dev/null
Stty-raw
Stty Echo
Stty $SAVEDSTTY
}
echo ""
echo "Press any key to Start...or press CTRL + C to cancel"
Char= ' Get_char '
}
# Download Files
Function download_files () {
if [s ez_setup.py]; then
&nbs p; echo "ez_setup.py [found]"
else
echo "ez_setup.py not found!!! Download Now ... "
if! wget--no-check-certificate https:// Bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py;then
echo "Failed to download ez_setup.py!"
exit 1
fi
fi
}
# Config Shadowsocks
function Config_shadowsocks () {
Touch/etc/config.json
Cat >>/etc/config.json<<-eof
{
' Server ': ' ${ip} ',
"Server_port": 8989,
"Local_port": 1080,
"Password": "${shadowsockspwd}",
"Timeout": 600,
"Method": "AES-256-CFB"
}
Eof
}
# iptables Set
function Iptables_set () {
/sbin/service iptables status 1>/dev/null 2>&1
If [$?-eq 0]; Then
/sbin/iptables-a input-m State--state new-m tcp-p TCP--dport 8989-j ACCEPT
/etc/rc.d/init.d/iptables Save
/etc/init.d/iptables restart
Fi
}
# Install
function Install () {
Yum install-y wget openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent
Yum install-y automake make Curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel
Python ez_setup.py Install
Easy_install pip
Pip Install Shadowsocks
Pip Install M2crypto
Pip Install Greenlet
Pip Install Gevent
Nohup ssserver-c/etc/config.json >/dev/null 2>&1 &
Clear
echo ""
echo "Congratulations, shadowsocks install completed!"
Echo-e "Your Server ip:33[41;37m ${ip} 33[0m"
Echo-e "Your Server port:33[41;37m 8989 33[0m"
Echo-e "Your password:33[41;37m ${shadowsockspwd} 33[0m"
Echo-e "Your Proxy port:33[41;37m 1080 33[0m"
echo ""
echo ""
echo "Welcome to Visit:http://teddysun.com/342.html"
echo "Enjoy it! ^_^"
echo ""
echo ""
}
# Uninstall Shadowsocks
function Uninstall_shadowsocks () {
Killall Ssserver
Pip Uninstall Shadowsocks
}
# initialization Step
Action=$1
[Z $] && action=install
Case "$action" in
Install
Install_shadowsocks
;;
Uninstall
Uninstall_shadowsocks
;;
*)
echo "Usage: ' basename $ ' {install|uninstall)}"
;;
Esac
|