update comment
This commit is contained in:
parent
5161ff3d17
commit
282e9a8770
|
|
@ -1,4 +1,4 @@
|
||||||
#! /bin/bash
|
#!/usr/bin/env bash
|
||||||
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
|
||||||
#=================================================================#
|
#=================================================================#
|
||||||
|
|
@ -15,20 +15,22 @@ echo "#############################################################"
|
||||||
echo "# One click Install ShadowsocksR Server #"
|
echo "# One click Install ShadowsocksR Server #"
|
||||||
echo "# Intro: https://shadowsocks.be/9.html #"
|
echo "# Intro: https://shadowsocks.be/9.html #"
|
||||||
echo "# Author: Teddysun <i@teddysun.com> #"
|
echo "# Author: Teddysun <i@teddysun.com> #"
|
||||||
echo "# Thanks: @breakwa11 <https://twitter.com/breakwa11> #"
|
echo "# Github: https://github.com/breakwa11/shadowsocks #"
|
||||||
echo "#############################################################"
|
echo "#############################################################"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
#Current folder
|
#Current folder
|
||||||
cur_dir=`pwd`
|
cur_dir=`pwd`
|
||||||
# Get public IP address
|
# Get public IP address
|
||||||
IP=$(ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1)
|
get_ip(){
|
||||||
if [[ "$IP" = "" ]]; then
|
local IP=$( ip addr | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | egrep -v "^192\.168|^172\.1[6-9]\.|^172\.2[0-9]\.|^172\.3[0-2]\.|^10\.|^127\.|^255\.|^0\." | head -n 1 )
|
||||||
IP=$(wget -qO- -t1 -T2 ipv4.icanhazip.com)
|
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipv4.icanhazip.com )
|
||||||
fi
|
[ -z ${IP} ] && IP=$( wget -qO- -t1 -T2 ipinfo.io/ip )
|
||||||
|
[ ! -z ${IP} ] && echo ${IP} || echo
|
||||||
|
}
|
||||||
|
|
||||||
# Make sure only root can run our script
|
# Make sure only root can run our script
|
||||||
function rootness(){
|
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
|
||||||
|
|
@ -36,7 +38,7 @@ function rootness(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check OS
|
# Check OS
|
||||||
function checkos(){
|
checkos(){
|
||||||
if [ -f /etc/redhat-release ];then
|
if [ -f /etc/redhat-release ];then
|
||||||
OS='CentOS'
|
OS='CentOS'
|
||||||
elif [ ! -z "`cat /etc/issue | grep bian`" ];then
|
elif [ ! -z "`cat /etc/issue | grep bian`" ];then
|
||||||
|
|
@ -50,7 +52,7 @@ function checkos(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get version
|
# Get version
|
||||||
function getversion(){
|
getversion(){
|
||||||
if [[ -s /etc/redhat-release ]];then
|
if [[ -s /etc/redhat-release ]];then
|
||||||
grep -oE "[0-9.]+" /etc/redhat-release
|
grep -oE "[0-9.]+" /etc/redhat-release
|
||||||
else
|
else
|
||||||
|
|
@ -59,7 +61,7 @@ function getversion(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# CentOS version
|
# CentOS version
|
||||||
function centosversion(){
|
centosversion(){
|
||||||
local code=$1
|
local code=$1
|
||||||
local version="`getversion`"
|
local version="`getversion`"
|
||||||
local main_ver=${version%%.*}
|
local main_ver=${version%%.*}
|
||||||
|
|
@ -71,7 +73,7 @@ function centosversion(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable selinux
|
# Disable selinux
|
||||||
function disable_selinux(){
|
disable_selinux(){
|
||||||
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then
|
||||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
|
||||||
setenforce 0
|
setenforce 0
|
||||||
|
|
@ -79,7 +81,7 @@ fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pre-installation settings
|
# Pre-installation settings
|
||||||
function pre_install(){
|
pre_install(){
|
||||||
# Not support CentOS 5
|
# Not support CentOS 5
|
||||||
if centosversion 5; then
|
if centosversion 5; then
|
||||||
echo "Not support CentOS 5, please change OS to CentOS 6+/Debian 7+/Ubuntu 12+ and retry."
|
echo "Not support CentOS 5, please change OS to CentOS 6+/Debian 7+/Ubuntu 12+ and retry."
|
||||||
|
|
@ -100,9 +102,9 @@ function pre_install(){
|
||||||
echo -e "Please input port for ShadowsocksR [1-65535]:"
|
echo -e "Please input port for ShadowsocksR [1-65535]:"
|
||||||
read -p "(Default port: 8989):" shadowsocksport
|
read -p "(Default port: 8989):" shadowsocksport
|
||||||
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
|
[ -z "$shadowsocksport" ] && shadowsocksport="8989"
|
||||||
expr $shadowsocksport + 0 &>/dev/null
|
expr ${shadowsocksport} + 0 &>/dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
if [ $shadowsocksport -ge 1 ] && [ $shadowsocksport -le 65535 ]; then
|
if [ ${shadowsocksport} -ge 1 ] && [ ${shadowsocksport} -le 65535 ]; then
|
||||||
echo
|
echo
|
||||||
echo "---------------------------"
|
echo "---------------------------"
|
||||||
echo "port = $shadowsocksport"
|
echo "port = $shadowsocksport"
|
||||||
|
|
@ -136,11 +138,11 @@ function pre_install(){
|
||||||
apt-get -y update
|
apt-get -y update
|
||||||
apt-get -y install python python-dev python-pip python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential
|
apt-get -y install python python-dev python-pip python-m2crypto curl wget unzip gcc swig automake make perl cpio build-essential
|
||||||
fi
|
fi
|
||||||
cd $cur_dir
|
cd ${cur_dir}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download files
|
# Download files
|
||||||
function download_files(){
|
download_files(){
|
||||||
# Download libsodium file
|
# Download libsodium file
|
||||||
if ! wget --no-check-certificate -O libsodium-1.0.11.tar.gz https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz; then
|
if ! wget --no-check-certificate -O libsodium-1.0.11.tar.gz https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz; then
|
||||||
echo "Failed to download libsodium file!"
|
echo "Failed to download libsodium file!"
|
||||||
|
|
@ -166,7 +168,7 @@ function download_files(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# firewall set
|
# firewall set
|
||||||
function firewall_set(){
|
firewall_set(){
|
||||||
echo "firewall set start..."
|
echo "firewall set start..."
|
||||||
if centosversion 6; then
|
if centosversion 6; then
|
||||||
/etc/init.d/iptables status > /dev/null 2>&1
|
/etc/init.d/iptables status > /dev/null 2>&1
|
||||||
|
|
@ -205,7 +207,7 @@ function firewall_set(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Config ShadowsocksR
|
# Config ShadowsocksR
|
||||||
function config_shadowsocks(){
|
config_shadowsocks(){
|
||||||
cat > /etc/shadowsocks.json<<-EOF
|
cat > /etc/shadowsocks.json<<-EOF
|
||||||
{
|
{
|
||||||
"server":"0.0.0.0",
|
"server":"0.0.0.0",
|
||||||
|
|
@ -229,15 +231,15 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install ShadowsocksR
|
# Install ShadowsocksR
|
||||||
function install_ss(){
|
install_ss(){
|
||||||
# Install libsodium
|
# Install libsodium
|
||||||
tar zxf libsodium-1.0.11.tar.gz
|
tar zxf libsodium-1.0.11.tar.gz
|
||||||
cd $cur_dir/libsodium-1.0.11
|
cd ${cur_dir}/libsodium-1.0.11
|
||||||
./configure && make && make install
|
./configure && make && make install
|
||||||
echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
|
echo "/usr/local/lib" > /etc/ld.so.conf.d/local.conf
|
||||||
ldconfig
|
ldconfig
|
||||||
# Install ShadowsocksR
|
# Install ShadowsocksR
|
||||||
cd $cur_dir
|
cd ${cur_dir}
|
||||||
unzip -q manyuser.zip
|
unzip -q manyuser.zip
|
||||||
mv shadowsocks-manyuser/shadowsocks /usr/local/
|
mv shadowsocks-manyuser/shadowsocks /usr/local/
|
||||||
if [ -f /usr/local/shadowsocks/server.py ]; then
|
if [ -f /usr/local/shadowsocks/server.py ]; then
|
||||||
|
|
@ -254,7 +256,7 @@ function install_ss(){
|
||||||
clear
|
clear
|
||||||
echo
|
echo
|
||||||
echo "Congratulations, ShadowsocksR install completed!"
|
echo "Congratulations, ShadowsocksR install completed!"
|
||||||
echo -e "Server IP: \033[41;37m ${IP} \033[0m"
|
echo -e "Server IP: \033[41;37m $(get_ip) \033[0m"
|
||||||
echo -e "Server Port: \033[41;37m ${shadowsocksport} \033[0m"
|
echo -e "Server Port: \033[41;37m ${shadowsocksport} \033[0m"
|
||||||
echo -e "Password: \033[41;37m ${shadowsockspwd} \033[0m"
|
echo -e "Password: \033[41;37m ${shadowsockspwd} \033[0m"
|
||||||
echo -e "Local IP: \033[41;37m 127.0.0.1 \033[0m"
|
echo -e "Local IP: \033[41;37m 127.0.0.1 \033[0m"
|
||||||
|
|
@ -277,8 +279,8 @@ function install_ss(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install cleanup
|
# Install cleanup
|
||||||
function install_cleanup(){
|
install_cleanup(){
|
||||||
cd $cur_dir
|
cd ${cur_dir}
|
||||||
rm -f manyuser.zip
|
rm -f manyuser.zip
|
||||||
rm -rf shadowsocks-manyuser
|
rm -rf shadowsocks-manyuser
|
||||||
rm -f libsodium-1.0.11.tar.gz
|
rm -f libsodium-1.0.11.tar.gz
|
||||||
|
|
@ -287,11 +289,11 @@ function install_cleanup(){
|
||||||
|
|
||||||
|
|
||||||
# Uninstall ShadowsocksR
|
# Uninstall ShadowsocksR
|
||||||
function uninstall_shadowsocks(){
|
uninstall_shadowsocks(){
|
||||||
printf "Are you sure uninstall ShadowsocksR? (y/n) "
|
printf "Are you sure uninstall ShadowsocksR? (y/n) "
|
||||||
printf "\n"
|
printf "\n"
|
||||||
read -p "(Default: n):" answer
|
read -p "(Default: n):" answer
|
||||||
if [ -z $answer ]; then
|
if [ -z ${answer} ]; then
|
||||||
answer="n"
|
answer="n"
|
||||||
fi
|
fi
|
||||||
if [ "$answer" = "y" ]; then
|
if [ "$answer" = "y" ]; then
|
||||||
|
|
@ -316,7 +318,7 @@ function uninstall_shadowsocks(){
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install ShadowsocksR
|
# Install ShadowsocksR
|
||||||
function install_shadowsocks(){
|
install_shadowsocks(){
|
||||||
checkos
|
checkos
|
||||||
rootness
|
rootness
|
||||||
disable_selinux
|
disable_selinux
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user