Support CentOS 7

This commit is contained in:
Teddysun 2015-01-07 14:23:02 +08:00
parent 6b7cb9c7f5
commit 1c5bcef2d4

View File

@ -18,17 +18,6 @@ echo "#"
echo "#############################################################" echo "#############################################################"
echo "" echo ""
# 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 # Make sure only root can run our script
function rootness(){ function rootness(){
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
@ -68,12 +57,9 @@ fi
# Pre-installation settings # Pre-installation settings
function pre_install(){ function pre_install(){
# Not support CentOS 5.x and 7.x # Not support CentOS 5
if centosversion 5; then if centosversion 5; then
echo "Not support CentOS 5.x, please change to CentOS 6.x and try again." echo "Not support CentOS 5.x, please change to CentOS 6 or 7 and try again."
exit 1
elif centosversion 7; then
echo "Not support CentOS 7.x, please change to CentOS 6.x and try again."
exit 1 exit 1
fi fi
#Set shadowsocks config password #Set shadowsocks config password
@ -105,6 +91,8 @@ function pre_install(){
if [ -z $IP ]; then if [ -z $IP ]; then
IP=`curl -s ifconfig.me/ip` IP=`curl -s ifconfig.me/ip`
fi fi
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
echo ""
#Current folder #Current folder
cur_dir=`pwd` cur_dir=`pwd`
cd $cur_dir cd $cur_dir
@ -147,14 +135,19 @@ EOF
# iptables set # iptables set
function iptables_set(){ function iptables_set(){
echo "iptables start setting..."
/sbin/service iptables status 1>/dev/null 2>&1 /sbin/service iptables status 1>/dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
/etc/init.d/iptables status | grep '8989' | grep 'ACCEPT' >/dev/null 2>&1 /etc/init.d/iptables status | grep '8989' | grep 'ACCEPT' >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
/sbin/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8989 -j ACCEPT /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 save
/etc/init.d/iptables restart /etc/init.d/iptables restart
else
echo "port 8989 has been set up."
fi fi
else
echo "iptables looks like shutdown, please manually set it if necessary."
fi fi
} }
@ -195,6 +188,7 @@ function install(){
echo "Welcome to visit:http://teddysun.com/342.html" echo "Welcome to visit:http://teddysun.com/342.html"
echo "Enjoy it!" echo "Enjoy it!"
echo "" echo ""
exit 0
else else
echo "" echo ""
echo "pip install failed! Please visit http://teddysun.com/342.html and contact." echo "pip install failed! Please visit http://teddysun.com/342.html and contact."
@ -237,6 +231,19 @@ function uninstall_shadowsocks(){
fi fi
} }
# Install Shadowsocks-python
function install_shadowsocks(){
rootness
disable_selinux
pre_install
download_files
config_shadowsocks
if ! centosversion 7; then
iptables_set
fi
install
}
# Initialization step # Initialization step
action=$1 action=$1
[ -z $1 ] && action=install [ -z $1 ] && action=install