-
Notifications
You must be signed in to change notification settings - Fork 131
/
ssr
248 lines (233 loc) · 6.63 KB
/
ssr
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# 检测是否以 root 用户运行
[ $(id -u) != "0" ] && { echo "Error: You must be root to run this script"; exit 1; }
SSR_restart="/etc/init.d/shadowsocks restart"
SSR_stop="/etc/init.d/shadowsocks stop"
SSRGo_start="bash /usr/local/bin/ssr"
Change_config="bash /usr/local/bin/ssr change_config"
Service_mgr="bash /usr/local/bin/ssr service_mgr"
QR_Code="/root/ssr_qrcode.png"
Show_Conf="python /usr/local/SSR.Go/connectinfo.py"
ApplyConf() {
${Show_Conf}
echo ""
send_qrcode
${SSR_restart}
echo ""
echo $1
${Change_config}
}
Uninstall_SSR.Go() {
printf "您想同时卸载 ShadowsocksRR 和 SSR.Go 吗? (y/n)"
printf "\n"
read -p "(Default: n):" response
[ -z ${response} ] && response="n"
if [ "${response}" == "y" ] || [ "${response}" == "Y" ]; then
echo "停止 ssrr 服务....."
${SSR_stop}
wget -qO- https://github.com/leitbogioro/SSR.Go/raw/master/ssrmain.sh && bash ssrmain.sh uninstall
cd /usr/local/
rm -rf SSR.Go
else
echo
echo "卸载已取消, 未执行任何操作..."
echo
fi
}
# 服务管理
service_mgr(){
echo ""
echo "0.返回上一级"
echo "1.启动服务"
echo "2.停止服务"
echo "3.重启服务"
echo "4.运行状态"
echo "5.运行日志"
echo "6.卸载 SSR.Go"
echo "按数字键选择功能,按回车键退出"
while :; do echo
read -n1 -p "请选择: " schoice
if [[ ! $schoice =~ ^[0-6]$ ]]; then
if [[ -z ${schoice} ]]; then
exit 0
fi
echo "输入错误! 请输入正确的数字!"
else
echo ""
break
fi
done
# 返回上一级
if [[ ${schoice} == 0 ]]; then
${SSRGo_start}
fi
# 启动ssr
if [[ ${schoice} == 1 ]]; then
python /usr/local/SSR.Go/addportrules.py
/etc/init.d/shadowsocks start
# 这里需要添加生成二维码模块
echo "ssrr 服务启动成功!"
${Service_mgr}
fi
if [[ ${schoice} == 2 ]]; then
${SSR_stop}
echo "ssrr 服务停止成功!"
${Service_mgr}
fi
if [[ ${schoice} == 3 ]]; then
python /usr/local/SSR.Go/addportrules.py
${SSR_restart}
# 这里需要添加生成二维码模块
echo "ssrr 服务已重启!"
${Service_mgr}
fi
if [[ ${schoice} == 4 ]]; then
/etc/init.d/shadowsocks status
${Service_mgr}
fi
if [[ ${schoice} == 5 ]]; then
echo "按 Ctrl + C 以退出日志功能"
echo ""
tail -f /var/log/shadowsocksr.log
${Service_mgr}
fi
if [[ ${schoice} == 6 ]]; then
Uninstall_SSR.Go
fi
}
# 更改配置
change_config(){
echo ""
echo "0.返回上一级"
echo "1.更改密码"
echo "2.更改端口"
echo "3.更改加密方式"
echo "4.更改协议"
echo "5.更改混淆模式"
echo "6.设置重定向参数"
echo "按数字键选择功能,按回车键退出"
while :; do echo
read -n1 -p "请选择: " changechoice
if [[ ! $changechoice =~ ^[0-6]$ ]]; then
if [[ -z ${changechoice} ]];then
exit 0
fi
echo "输入错误! 请输入正确的数字!"
else
echo ""
break
fi
done
# 返回上一级
if [[ ${changechoice} == 0 ]]; then
${SSRGo_start}
fi
# 更改密码
if [[ ${changechoice} == 1 ]]; then
python /usr/local/SSR.Go/changepwd.py
ApplyConf "密码配置已完成!"
fi
# 更改端口
if [[ ${changechoice} == 2 ]]; then
python /usr/local/SSR.Go/changeport.py
python /usr/local/SSR.Go/addportrules.py
ApplyConf "端口配置已完成!"
fi
# 更改加密
if [[ ${changechoice} == 3 ]]; then
python /usr/local/SSR.Go/changemethod.py
ApplyConf "加密方式配置已完成!"
fi
# 更改协议
if [[ ${changechoice} == 4 ]]; then
python /usr/local/SSR.Go/changeprotocol.py
ApplyConf "传输协议配置已完成!"
fi
# 更改混淆
if [[ ${changechoice} == 5 ]]; then
python /usr/local/SSR.Go/changeobfs.py
ApplyConf "混淆模式配置已完成!"
fi
# 设置重定向
if [[ ${changechoice} == 6 ]]; then
python /usr/local/SSR.Go/setredirect.py
ApplyConf "重定向配置已完成!"
fi
}
# 传送二维码
send_qrcode(){
read -n1 -p "==是否将 SSR 客户端配置二维码下载到你的电脑?(y/n)==" ans
if [[ ${ans} =~ [yY] ]]; then
sz /root/ssr_qrcode.png
echo -e "\n"
echo "SSR 二维码已传送完成!"
else
echo -e "\n"
echo "传送已取消!"
fi
}
"$@"
echo ""
echo "欢迎使用 ssr.go 管理助手"
echo ""
echo "1.服务管理"
echo "2.更改配置"
echo "3.查看配置链接/下载手机端二维码"
echo "4.更新ssr和ssr.go"
echo "5.更换语言版本(Switch to English version)"
echo "请输入数字选择功能(按 Ctrl+C 退出):"
while :; do echo
read -n1 -p "请选择: " choice
if [[ ! $choice =~ ^[1-5]$ ]]; then
if [[ -z ${choice} ]];then
exit 0
fi
echo -e "\n"
echo "输入错误! 请输入正确的数字!"
else
echo ""
break
fi
done
# 更新ssr和ssr.go的操作
if [[ ${choice} == 4 ]]; then
bash -c "$(curl -fsSL https://git.io/JeVEg)"
fi
# 切换语言版本
if [[ ${choice} == 5 ]]; then
echo "SSR.Go 简体中文版和英文版只允许同时运行一个,不可共存,是否继续操作?(y/n)"
read -n1 -p "Only one version of simplified Chinese or English version of SSR.Go can run, surely it? (y/n)" ans
echo -e "\n"
if [[ ${ans} =~ [yY] ]]; then
echo "停止 ssrr 服务....."
${SSR_stop}
cd /usr/local/
rm -R SSR.Go
git clone -b En https://github.com/leitbogioro/SSR.Go
chmod +x /usr/local/bin/ssr
echo "English version of SSR.Go installed successfully!"
echo "Input 'ssr' then press enter to start!"
exit
else
echo "未执行任何操作!"
${SSRGo_start}
fi
fi
# 服务管理模块
if [[ ${choice} == 1 ]]; then
service_mgr
fi
# 更改配置模块
if [[ ${choice} == 2 ]]; then
change_config
fi
# 查看服务信息模块
if [[ ${choice} == 3 ]]; then
rm -rf ${QR_Code}
echo ""
${Show_Conf}
echo ""
send_qrcode
${SSRGo_start}
fi