CentOS under Shadowsocks One-click installation script

Source: Internet
Author: User
Tags curl get ip openssl centos iptables server port


This script applies to the environment:
System support: Centos/redhat/fedora
Memory Requirements: ≥64m
Date: February 16, 2014

About this script:
One-click to install the Python version of Shadowsocks, while installing the Python package tool PIP.


Default configuration:
Server port: 8989
Client Port: 1080
Password: Set yourself (if not set, default is Teddysun.com)

Client Downloads:
http://sourceforge.net/projects/shadowsocksgui/files/dist/

How to use:
Log on using the root user to run the following command:

The code is as follows Copy Code

wget--no-check-certificate https://raw2.github.com/teddysun/shadowsocks_install/master/shadowsocks.sh
chmod +x shadowsocks.sh
./shadowsocks.sh 2>&1 | After the tee Shadowsocks.log installation is complete, the script prompts as follows:
Congratulations, shadowsocks install completed!
Your Server IP: (Your server IP)
Your Server port:8989
Your Password: (You set the password like www.111cn.net)
Your Proxy Port:

Enjoy it! ^_^

Uninstall method:
Log on using the root user to run the following command:

The code is as follows Copy Code

./shadowsocks.sh Uninstall

Final Payment shadowsocks.sh file code

The code is as follows Copy Code

#! /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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.