-
Notifications
You must be signed in to change notification settings - Fork 131
/
install.sh
409 lines (371 loc) · 14.3 KB
/
install.sh
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/bash
stty erase ^H
red='\e[91m'
green='\e[92m'
yellow='\e[94m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
_red() { echo -e ${red}$*${none}; }
_green() { echo -e ${green}$*${none}; }
_yellow() { echo -e ${yellow}$*${none}; }
_magenta() { echo -e ${magenta}$*${none}; }
_cyan() { echo -e ${cyan}$*${none}; }
# Root
[[ $(id -u) != 0 ]] && echo -e "\n 请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1
cmd="apt-get"
sys_bit=$(uname -m)
case $sys_bit in
'amd64' | x86_64) ;;
*)
echo -e "
这个 ${red}安装脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
" && exit 1
;;
esac
if [[ $(command -v apt-get) || $(command -v yum) ]] && [[ $(command -v systemctl) ]]; then
if [[ $(command -v yum) ]]; then
cmd="yum"
fi
else
echo -e "
这个 ${red}安装脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
" && exit 1
fi
if [ ! -d "/etc/MinerProxy/" ]; then
mkdir /etc/MinerProxy/
fi
error() {
echo -e "\n$red 输入错误!$none\n"
}
install_download() {
installPath="/etc/MinerProxy"
$cmd update -y
if [[ $cmd == "apt-get" ]]; then
$cmd install -y lrzsz git zip unzip curl wget supervisor
service supervisor restart
else
$cmd install -y epel-release
$cmd update -y
$cmd install -y lrzsz git zip unzip curl wget supervisor
systemctl enable supervisord
service supervisord restart
fi
[ -d ./MinerProxy ] && rm -rf ./MinerProxy
mkdir ./MinerProxy
echo "请选择安装版本"
echo " 1、v6.0.4"
echo " 2、v6.0.5"
read -p "$(echo -e "请输入[1-2]:")" choose
case $choose in
1)
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/MinerProxy_6.0.4_linux -O ./MinerProxy/MinerProxy_6.0.4_linux
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.key -O ./MinerProxy/server.key
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.pem -O ./MinerProxy/server.pem
cp -rf ./MinerProxy /etc/
if [[ ! -d $installPath ]]; then
echo
echo -e "$red 复制文件出错了...$none"
echo
echo -e " 使用最新版本的Ubuntu或者CentOS再试试"
echo
exit 1
fi
echo
echo "下载完成,开启守护"
echo
chmod a+x $installPath/MinerProxy_6.0.4_linux
if [ -d "/etc/supervisor/conf/" ]; then
rm /etc/supervisor/conf/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.4_linux" >>/etc/supervisor/conf/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf/MinerProxy.conf
elif [ -d "/etc/supervisor/conf.d/" ]; then
rm /etc/supervisor/conf.d/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.4_linux" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
elif [ -d "/etc/supervisord.d/" ]; then
rm /etc/supervisord.d/MinerProxy.ini -f
echo "[program:MinerProxy]" >>/etc/supervisord.d/MinerProxy.ini
echo "command=${installPath}/MinerProxy_6.0.4_linux" >>/etc/supervisord.d/MinerProxy.ini
echo "directory=${installPath}/" >>/etc/supervisord.d/MinerProxy.ini
echo "autostart=true" >>/etc/supervisord.d/MinerProxy.ini
echo "autorestart=true" >>/etc/supervisord.d/MinerProxy.ini
else
echo
echo "----------------------------------------------------------------"
echo
echo " Supervisor安装目录没了,安装失败,请更换系统在尝试安装!"
echo
exit 1
fi
;;
2)
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/MinerProxy_6.0.5_linux -O ./MinerProxy/MinerProxy_6.0.5_linux
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.key -O ./MinerProxy/server.key
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.pem -O ./MinerProxy/server.pem
cp -rf ./MinerProxy /etc/
if [[ ! -d $installPath ]]; then
echo
echo -e "$red 复制文件出错了...$none"
echo
echo -e " 使用最新版本的Ubuntu或者CentOS再试试"
echo
exit 1
fi
echo
echo "下载完成,开启守护"
echo
chmod a+x $installPath/MinerProxy_6.0.5_linux
if [ -d "/etc/supervisor/conf/" ]; then
rm /etc/supervisor/conf/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisor/conf/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf/MinerProxy.conf
elif [ -d "/etc/supervisor/conf.d/" ]; then
rm /etc/supervisor/conf.d/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
elif [ -d "/etc/supervisord.d/" ]; then
rm /etc/supervisord.d/MinerProxy.ini -f
echo "[program:MinerProxy]" >>/etc/supervisord.d/MinerProxy.ini
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisord.d/MinerProxy.ini
echo "directory=${installPath}/" >>/etc/supervisord.d/MinerProxy.ini
echo "autostart=true" >>/etc/supervisord.d/MinerProxy.ini
echo "autorestart=true" >>/etc/supervisord.d/MinerProxy.ini
else
echo
echo "----------------------------------------------------------------"
echo
echo " Supervisor安装目录没了,安装失败,请更换系统在尝试安装!"
echo
exit 1
fi
;;
*)
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/MinerProxy_6.0.5_linux -O ./MinerProxy/MinerProxy_6.0.5_linux
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.key -O ./MinerProxy/server.key
wget https://raw.githubusercontent.com/MinerPr0xy/MinerProxy/main/server.pem -O ./MinerProxy/server.pem
cp -rf ./MinerProxy /etc/
if [[ ! -d $installPath ]]; then
echo
echo -e "$red 复制文件出错了...$none"
echo
echo -e " 使用最新版本的Ubuntu或者CentOS再试试"
echo
exit 1
fi
echo
echo "下载完成,开启守护"
echo
chmod a+x $installPath/MinerProxy_6.0.5_linux
if [ -d "/etc/supervisor/conf/" ]; then
rm /etc/supervisor/conf/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisor/conf/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf/MinerProxy.conf
elif [ -d "/etc/supervisor/conf.d/" ]; then
rm /etc/supervisor/conf.d/MinerProxy.conf -f
echo "[program:MinerProxy]" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "directory=${installPath}/" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autostart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
echo "autorestart=true" >>/etc/supervisor/conf.d/MinerProxy.conf
elif [ -d "/etc/supervisord.d/" ]; then
rm /etc/supervisord.d/MinerProxy.ini -f
echo "[program:MinerProxy]" >>/etc/supervisord.d/MinerProxy.ini
echo "command=${installPath}/MinerProxy_6.0.5_linux" >>/etc/supervisord.d/MinerProxy.ini
echo "directory=${installPath}/" >>/etc/supervisord.d/MinerProxy.ini
echo "autostart=true" >>/etc/supervisord.d/MinerProxy.ini
echo "autorestart=true" >>/etc/supervisord.d/MinerProxy.ini
else
echo
echo "----------------------------------------------------------------"
echo
echo " Supervisor安装目录没了,安装失败,请更换系统在尝试安装!"
echo
exit 1
fi
;;
esac
}
start_write_config() {
if [[ $cmd == "apt-get" ]]; then
ufw disable
else
systemctl stop firewalld
sleep 1
systemctl disable firewalld.service
fi
changeLimit="n"
if [ $(grep -c "root soft nofile" /etc/security/limits.conf) -eq '0' ]; then
echo "root soft nofile 102400" >>/etc/security/limits.conf
changeLimit="y"
fi
if [ $(grep -c "root hard nofile" /etc/security/limits.conf) -eq '0' ]; then
echo "root hard nofile 102400" >>/etc/security/limits.conf
changeLimit="y"
fi
if [ $(grep -c "root soft nofile" /etc/systemd/system.conf) -eq '0' ]; then
echo "DefaultLimitNOFILE=102400" >>/etc/systemd/system.conf
changeLimit="y"
fi
if [ $(grep -c "root hard nofile" /etc/systemd/system.conf) -eq '0' ]; then
echo "DefaultLimitNPROC=102400" >>/etc/systemd/system.conf
changeLimit="y"
fi
if [ $(grep -c "root soft nofile" /etc/systemd/user.conf) -eq '0' ]; then
echo "DefaultLimitNOFILE=102400" >>/etc/systemd/user.conf
changeLimit="y"
fi
if [ $(grep -c "root hard nofile" /etc/systemd/user.conf) -eq '0' ]; then
echo "DefaultLimitNPROC=102400" >>/etc/systemd/user.conf
changeLimit="y"
fi
clear
echo
echo "----------------------------------------------------------------"
echo
if [[ "$changeLimit" = "y" ]]; then
echo "系统连接数限制已经改了,如果第一次运行本程序需要重启!"
echo
fi
sleep 1
supervisorctl reload
sleep 1
echo "本机防火墙端口随机已经开放,如果还无法连接,请到云服务商控制台操作安全组,放行对应的端口"
echo "默认端口:随机 默认密码:随机 访问管理界面:本机IP:随机端口"
echo
echo "安装完成...守护模式无日志,需要日志的请登录后台查看"
echo
echo "[*---------]"
sleep 1
echo "[**--------]"
sleep 1
echo "[***-------]"
sleep 1
echo "[****------]"
sleep 1
echo "[*****-----]"
sleep 1
echo "[******----]"
sleep 1
if [ -f /etc/MinerProxy/pwd.txt ]; then
echo
cat /etc/MinerProxy/pwd.txt
echo
else
echo "后台默认端口:19999"
echo "后台默认密码:https://github.com/MinerPr0xy/MinerProxy"
fi
echo "----------------------------------------------------------------"
}
uninstall() {
clear
if [ -d "/etc/supervisor/conf/" ]; then
rm /etc/supervisor/conf/MinerProxy.conf -f
elif [ -d "/etc/supervisor/conf.d/" ]; then
rm /etc/supervisor/conf.d/MinerProxy.conf -f
elif [ -d "/etc/supervisord.d/" ]; then
rm /etc/supervisord.d/MinerProxy.ini -f
fi
supervisorctl reload
echo -e "$yellow 已关闭自启动${none}"
}
Reset() {
clear
if [ -f "/etc/MinerProxy/config.json" ]; then
rm -f /etc/MinerProxy/config.json
fi
killall MinerProxy_6.0.0_linux
killall MinerProxy_6.0.1_linux
killall MinerProxy_6.0.2_linux
killall MinerProxy_6.0.3_linux
killall MinerProxy_6.0.4_linux
killall MinerProxy_6.0.5_linux
echo "----------------------------------------------------------------"
echo "成功重置配置文件"
echo
echo "[*---------]"
sleep 1
echo "[**--------]"
sleep 1
echo "[***-------]"
sleep 1
echo "[****------]"
sleep 1
echo "[*****-----]"
sleep 1
echo "[******----]"
sleep 1
if [ -f /etc/MinerProxy/pwd.txt ]; then
echo
cat /etc/MinerProxy/pwd.txt
echo
else
echo "后台默认端口:19999"
echo "后台默认密码:https://github.com/MinerPr0xy/MinerProxy"
fi
echo "----------------------------------------------------------------"
}
clear
while :; do
echo
echo "-------- MinerProxy 一键安装脚本 by:MinerPr1xy--------"
echo "Github下载地址:https://github.com/MinerPr0xy/MinerProxy"
echo "帮助稳定(编写中):https://minerproxy.gitbook.io/minerproxy/"
echo "官方电报群:https://t.me/Miner_Proxy"
echo "官方QQ群号:683918874"
echo
echo " 1. 安装(MinerProxy)"
echo
echo " 2. 卸载(MinerProxy)"
echo
echo " 3. 重启(MinerProxy)"
echo
echo " 4. 重置配置文件(后台端口和后台密码)"
echo
read -p "$(echo -e "请选择 [${magenta}1-4$none]:")" choose
case $choose in
1)
install_download
start_write_config
break
;;
2)
uninstall
break
;;
3)
killall MinerProxy_6.0.0_linux
killall MinerProxy_6.0.1_linux
killall MinerProxy_6.0.2_linux
killall MinerProxy_6.0.3_linux
killall MinerProxy_6.0.4_linux
killall MinerProxy_6.0.5_linux
echo "重启成功"
break
;;
4)
Reset
break
;;
*)
error
;;
esac
done