forked from leitbogioro/SSR.Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssrinstall
108 lines (94 loc) · 3.1 KB
/
ssrinstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#检查是否为Root
[ $(id -u) != "0" ] && { echo "发生错误,你必须以 root 用户执行此安装程序"; exit 1; }
# 脚本字体颜色
green='\033[0;32m'
red='\033[0;31m'
plain='\033[0m'
#检查系统信息
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 "你的操作系统不受支持,请选择在 Ubuntu/Debian/CentOS 操作系统上安装!"
exit 1
fi
#禁用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
# 输出 centos 系统大版本号
System_CentOS=`rpm -q centos-release|cut -d- -f1`
CentOS_Version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`
# CentOS 6 专用 python
py_for_centos="https://raw.githubusercontent.com/leitbogioro/SSR.Go/master/python_for_centos6.sh"
py_intall="python_for_centos6.sh"
install_python_for_CentOS6(){
yum install wget -y
wget ${py_for_centos}
if ! wget ${py_for_centos}; then
echo -e "[${red}错误${plain}] ${py_file} 下载失败,请检测你的网络!"
exit 1
fi
bash ${py_intall}
rm -rf /root/${py_intall}
}
# CentOS 7 专用 pip 源
pip_file="get-pip.py"
pip_url="https://bootstrap.pypa.io/get-pip.py"
install_python_for_CentOS7(){
yum install curl python -y
curl ${pip_url} -o ${pip_file}
if ! curl ${pip_url} -o ${pip_file}; then
echo -e "[${red}错误${plain}] ${pip_file} 下载失败,请检测你的网络!"
exit 1
fi
python ${pip_file}
rm -rf /root/${pip_file}
}
# Python QRCode 依赖
py_qrcode(){
pip install pillow
pip install qrcode
}
#安装依赖
if [[ ${OS} == 'CentOS' ]] && [[ ${CentOS_Version} -eq "7" ]]; then
yum update -y
yum install epel-release curl unzip git ntp ntpdate lrzsz -y
install_python_for_CentOS7
py_qrcode
elif [[ ${OS} == 'CentOS' ]] && [[ ${CentOS_Version} -eq "6" ]]; then
yum update -y
yum install epel-release wget unzip git ntp ntpdate lrzsz -y
install_python_for_CentOS6
py_qrcode
elif [[ ${OS} == 'CentOS' ]] && [[ ${CentOS_Version} -le "5" ]]; then
echo "您的系统版本是(${System_CentOS} ${CentOS_Version}),此系统不受支持,SSR.Go 安装程序即将退出!"
exit 1
else
curl sudo -E bash -
apt-get update
apt-get install curl unzip git ntp wget ntpdate python python-pip socat lrzsz -y
py_qrcode
fi
#克隆ssr.go项目
cd /usr/local/
rm -R SSR.Go
git clone https://github.com/leitbogioro/SSR.Go
#安装shadowsocksRR主程序
bash <(curl -L -s https://git.io/fNpEa)
#配置ssr初始环境
rm -rf /usr/local/bin/ssr
ln -sf /usr/local/SSR.Go/ssr /usr/local/bin
chmod +x /usr/local/bin/ssr
chmod +x /etc/init.d/shadowsocks
chmod +x /usr/local/shadowsocks/
/etc/init.d/shadowsocks start
clear
echo "SSR.Go 和 ShadowSocksR 安装成功!"
echo "输入 ssr 并回车即可使用"