Add support Debian & Ubuntu
This commit is contained in:
parent
e93c63147a
commit
6e64ccc4e2
102
shadowsocks.sh
102
shadowsocks.sh
|
|
@ -2,15 +2,16 @@
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
export PATH
|
export PATH
|
||||||
#===============================================================================================
|
#===============================================================================================
|
||||||
# System Required: CentOS6.x (32bit/64bit)
|
# System Required: CentOS 6,7, Debian, Ubuntu
|
||||||
# Description: Install Shadowsocks(Python) for CentOS
|
# Description: One click Install Shadowsocks(Python)
|
||||||
# Author: Teddysun <i@teddysun.com>
|
# Author: Teddysun <i@teddysun.com>
|
||||||
# Intro: http://teddysun.com/342.html
|
# Intro: http://teddysun.com/342.html
|
||||||
#===============================================================================================
|
#===============================================================================================
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
echo ""
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo "# Install Shadowsocks(Python) for CentOS 6 or 7 (32bit/64bit)"
|
echo "# One click Install Shadowsocks(Python)"
|
||||||
echo "# Intro: http://teddysun.com/342.html"
|
echo "# Intro: http://teddysun.com/342.html"
|
||||||
echo "#"
|
echo "#"
|
||||||
echo "# Author: Teddysun <i@teddysun.com>"
|
echo "# Author: Teddysun <i@teddysun.com>"
|
||||||
|
|
@ -20,10 +21,24 @@ echo ""
|
||||||
|
|
||||||
# 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
|
||||||
echo "Error:This script must be run as root!" 1>&2
|
echo "Error:This script must be run as root!" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check OS
|
||||||
|
function checkos(){
|
||||||
|
if [ -f /etc/redhat-release ];then
|
||||||
|
OS=CentOS
|
||||||
|
elif [ ! -z "`cat /etc/issue | grep bian`" ];then
|
||||||
|
OS=Debian
|
||||||
|
elif [ ! -z "`cat /etc/issue | grep Ubuntu`" ];then
|
||||||
|
OS=Ubuntu
|
||||||
|
else
|
||||||
|
echo "Not support OS, Please reinstall OS and retry!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get version
|
# Get version
|
||||||
|
|
@ -59,7 +74,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.x, please change to CentOS 6 or 7 and try again."
|
echo "Not support CentOS 5.x, please change to CentOS 6,7 or Debian or Ubuntu and try again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#Set shadowsocks config password
|
#Set shadowsocks config password
|
||||||
|
|
@ -83,13 +98,18 @@ function pre_install(){
|
||||||
echo "Press any key to start...or Press Ctrl+C to cancel"
|
echo "Press any key to start...or Press Ctrl+C to cancel"
|
||||||
char=`get_char`
|
char=`get_char`
|
||||||
#Install necessary dependencies
|
#Install necessary dependencies
|
||||||
yum install -y wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
yum install -y automake make curl curl-devel zlib-devel openssl-devel perl perl-devel cpio expat-devel gettext-devel
|
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
|
||||||
|
else
|
||||||
|
apt-get -y update
|
||||||
|
apt-get -y install python python-dev python-pip curl wget unzip gcc swig automake make perl cpio
|
||||||
|
fi
|
||||||
# Get IP address
|
# Get IP address
|
||||||
echo "Getting Public IP address, Please wait a moment..."
|
echo "Getting Public IP address, Please wait a moment..."
|
||||||
IP=`curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1`
|
IP=$(curl -s checkip.dyndns.com | cut -d' ' -f 6 | cut -d'<' -f 1)
|
||||||
if [ $? -ne 0 -o -z $IP ]; then
|
if [ $? -ne 0 -o -z $IP ]; then
|
||||||
IP=`curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}'`
|
IP=$(curl -s -4 ipinfo.io | grep "ip" | awk -F\" '{print $4}')
|
||||||
fi
|
fi
|
||||||
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
echo -e "Your main public IP is\t\033[32m$IP\033[0m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -100,19 +120,21 @@ function pre_install(){
|
||||||
|
|
||||||
# Download files
|
# Download files
|
||||||
function download_files(){
|
function download_files(){
|
||||||
if [ -f ez_setup.py ]; then
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
echo "ez_setup.py [found]"
|
if ! wget --no-check-certificate -O ez_setup.py https://bootstrap.pypa.io/ez_setup.py; then
|
||||||
else
|
|
||||||
echo "ez_setup.py not found!!!download now......"
|
|
||||||
if ! wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py; then
|
|
||||||
echo "Failed to download ez_setup.py!"
|
echo "Failed to download ez_setup.py!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
# Download shadowsocks chkconfig file
|
||||||
# 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
|
fi
|
||||||
|
else
|
||||||
|
if ! wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-debian -O /etc/init.d/shadowsocks; then
|
||||||
|
echo "Failed to download shadowsocks chkconfig file!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,23 +172,29 @@ function iptables_set(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install
|
# Install Shadowsocks
|
||||||
function install(){
|
function install_ss(){
|
||||||
which pip > /dev/null 2>&1
|
which pip > /dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
python ez_setup.py install
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
easy_install pip
|
python ez_setup.py install
|
||||||
|
easy_install pip
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -f /usr/bin/pip ]; then
|
if [ -f /usr/bin/pip ]; then
|
||||||
pip install M2Crypto
|
pip install M2Crypto
|
||||||
pip install greenlet
|
pip install greenlet
|
||||||
pip install gevent
|
pip install gevent
|
||||||
pip install shadowsocks
|
pip install shadowsocks
|
||||||
if [ -f /usr/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
|
||||||
chkconfig --add shadowsocks
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
chkconfig shadowsocks on
|
chkconfig --add shadowsocks
|
||||||
|
chkconfig shadowsocks on
|
||||||
|
else
|
||||||
|
update-rc.d shadowsocks defaults
|
||||||
|
fi
|
||||||
# Run shadowsocks in the background
|
# Run shadowsocks in the background
|
||||||
/etc/init.d/shadowsocks start
|
/etc/init.d/shadowsocks start
|
||||||
else
|
else
|
||||||
|
|
@ -214,7 +242,12 @@ function uninstall_shadowsocks(){
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
chkconfig --del shadowsocks
|
checkos
|
||||||
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
|
chkconfig --del shadowsocks
|
||||||
|
else
|
||||||
|
update-rc.d -f shadowsocks remove
|
||||||
|
fi
|
||||||
# delete config file
|
# delete config file
|
||||||
rm -f /etc/shadowsocks.json
|
rm -f /etc/shadowsocks.json
|
||||||
rm -f /var/run/shadowsocks.pid
|
rm -f /var/run/shadowsocks.pid
|
||||||
|
|
@ -232,15 +265,18 @@ function uninstall_shadowsocks(){
|
||||||
|
|
||||||
# Install Shadowsocks-python
|
# Install Shadowsocks-python
|
||||||
function install_shadowsocks(){
|
function install_shadowsocks(){
|
||||||
|
checkos
|
||||||
rootness
|
rootness
|
||||||
disable_selinux
|
disable_selinux
|
||||||
pre_install
|
pre_install
|
||||||
download_files
|
download_files
|
||||||
config_shadowsocks
|
config_shadowsocks
|
||||||
if ! centosversion 7; then
|
if [ "$OS" == 'CentOS' ]; then
|
||||||
iptables_set
|
if ! centosversion 7; then
|
||||||
|
iptables_set
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
install
|
install_ss
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initialization step
|
# Initialization step
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user