update iptables rules & Fix swig failed error

This commit is contained in:
Teddysun 2016-04-17 11:30:05 +09:00
parent 113415945c
commit 8c462518a0

View File

@ -123,7 +123,7 @@ function pre_install(){
#Install necessary dependencies
if [ "$OS" == 'CentOS' ]; then
yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent
yum install -y automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel
yum install -y automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel which
else
apt-get -y update
apt-get -y install python python-dev python-pip curl wget unzip gcc swig automake make perl cpio
@ -144,10 +144,6 @@ function pre_install(){
# Download files
function download_files(){
if [ "$OS" == 'CentOS' ]; then
if ! wget -t3 -T30 http://lamp.teddysun.com/ez_setup.py; then
echo "Failed to download ez_setup.py!"
exit 1
fi
# Download shadowsocks chkconfig file
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!"
@ -182,9 +178,10 @@ function iptables_set(){
echo "iptables start setting..."
/etc/init.d/iptables status 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
/etc/init.d/iptables status | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
/sbin/iptables -L -n | grep '${shadowsocksport}' | grep 'ACCEPT' >/dev/null 2>&1
if [ $? -ne 0 ]; then
/sbin/iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${shadowsocksport} -j ACCEPT
/sbin/iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${shadowsocksport} -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart
else
@ -200,12 +197,25 @@ function install_ss(){
which pip > /dev/null 2>&1
if [ $? -ne 0 ]; then
if [ "$OS" == 'CentOS' ]; then
python ez_setup.py install
easy_install pip
which easy_install > /dev/null 2>&1
if [ $? -eq 0 ]; then
easy_install pip
else
echo "easy_install command not found. please check it and try again."
exit 1
fi
fi
fi
if [ -f /usr/bin/pip ]; then
pip install M2Crypto
if [ "$OS" == 'CentOS' ]; then
if centosversion 6; then
# Fix swig failed error by install old version
pip install M2Crypto==0.22.3
fi
else
pip install M2Crypto
fi
pip install greenlet
pip install gevent
pip install shadowsocks
@ -226,7 +236,7 @@ function install_ss(){
exit 1
fi
clear
echo ""
echo
echo "Congratulations, shadowsocks install completed!"
echo -e "Your Server IP: \033[41;37m ${IP} \033[0m"
echo -e "Your Server Port: \033[41;37m ${shadowsocksport} \033[0m"
@ -234,13 +244,13 @@ function install_ss(){
echo -e "Your Local IP: \033[41;37m 127.0.0.1 \033[0m"
echo -e "Your Local Port: \033[41;37m 1080 \033[0m"
echo -e "Your Encryption Method: \033[41;37m aes-256-cfb \033[0m"
echo ""
echo
echo "Welcome to visit:https://teddysun.com/342.html"
echo "Enjoy it!"
echo ""
echo
exit 0
else
echo ""
echo
echo "pip install failed! Please visit https://teddysun.com/342.html and contact."
exit 1
fi
@ -288,12 +298,12 @@ function install_shadowsocks(){
pre_install
download_files
config_shadowsocks
install_ss
if [ "$OS" == 'CentOS' ]; then
if ! centosversion 7; then
if centosversion 6; then
iptables_set
fi
fi
install_ss
}
# Initialization step