-
Notifications
You must be signed in to change notification settings - Fork 87
/
mgr.sh
424 lines (424 loc) · 20.6 KB
/
mgr.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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
#!/bin/bash
RED="\033[0;31m"
NO_COLOR="\033[0m"
GREEN="\033[32m\033[01m"
BLUE="\033[0;36m"
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
isRoot(){
if [[ "$EUID" -ne 0 ]]; then
echo "false"
else
echo "true"
fi
}
genId(){
id1=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-8)
id2=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-4)
id3=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-4)
id4=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-4)
id5=$(cat /proc/sys/kernel/random/uuid | md5sum |cut -c 1-12)
id=$id1'-'$id2'-'$id3'-'$id4'-'$id5
echo "$id"
}
mgr(){
isRoot=$( isRoot )
if [[ "${isRoot}" != "true" ]]; then
echo -e "${RED_COLOR}error:${NO_COLOR}Please run this script as as root"
exit 1
else
#=========安装的trojan+caddy+tls一键脚本==============================
if [ -e "/usr/local/bin/caddy" -a -e "/usr/local/bin/trojan" ]; then
echo -e "
$FUCHSIA===================================================
${GREEN}系统检测到您目前安装的是trojan+caddy+tls一键脚本
$FUCHSIA===================================================
${GREEN}1. 停止trojan ${GREEN}2. 重启trojan
$FUCHSIA===================================================
${GREEN}3. 修改trojan密码 ${GREEN}4. 停止caddy
$FUCHSIA===================================================
${GREEN}5. 重启caddy ${GREEN}0. 啥也不做,退出
$FUCHSIA===================================================${NO_COLOR}"
read -p "请输入您要执行的操作的数字:" aNum
case $aNum in
1)systemctl stop trojan
echo -e "${GREEN}trojan服务停止${NO_COLOR}"
;;
2)systemctl restart trojan
echo -e "${GREEN}trojan服务启动${NO_COLOR}"
;;
3)if [ -f "/usr/local/etc/trojan/config.json" ]; then
password=`sed -n "1p" /usr/local/etc/trojan/trojan_info`
rm -f /var/www/${password}.html
rm -f /var/www/${password}.png
read -p "新密码:" password
fl="no"
while [[ $fl = "no" ]]; do
read -p "密码只能是字母和数字的组合:" password
for ((i=0;$i<${#password};i++));
do
str=${password:$i:1};
case "$str" in
[a-z]|[A-Z]|[0-9])fl="yes"
;;
*)echo "密码中含非法字符"
fl="no"
break
;;
esac
done
done
while [ "${password}" = "" ]; do
read -p "密码不能为空,请重新输入:" password
done
sed -i "8c \"$password\"," /usr/local/etc/trojan/config.json
domainname=`sed -n "2p" /usr/local/etc/trojan/trojan_info`
vps=`sed -n "3p" /usr/local/etc/trojan/trojan_info`
code="trojan://${password}@${domainname}:443"
qrencode -o /var/www/${password}.png -s 8 "${code}"
wget --no-check-certificate -O /var/www/trojan_tmpl.html https://raw.githubusercontent.com/JeannieStudio/all_install/master/trojan_tmpl.html
chmod +x /var/www/trojan_tmpl.html
end_time=$(echo | openssl s_client -servername $domainname -connect $domainname:443 2>/dev/null | openssl x509 -noout -dates |grep 'After'| awk -F '=' '{print $2}'| awk -F ' +' '{print $1,$2,$4 }' )
end_times=$(date +%s -d "$end_time")
now_time=$(date +%s -d "$(date | awk -F ' +' '{print $2,$3,$6}')")
RST=$(($((end_times-now_time))/(60*60*24)))
eval "cat <<EOF
$(< /var/www/trojan_tmpl.html)
EOF
" > /var/www/${password}.html
systemctl stop trojan
systemctl start trojan
sed -i "1c ${password}" /usr/local/etc/trojan/trojan_info
sed -i "/详情:https:/c 详情:https://${domainname}/${password}.html " /etc/motd
echo -e "${GREEN}恭喜你,密码修改成功,详情:https://${domainname}/${password}.html${NO_COLOR}"
else
echo -e "${RED}很遗憾,Trojan配置文件不存在${NO_COLOR}"
fi
systemctl start trojan
;;
4)caddy -service stop
echo -e "${GREEN}caddy服务停止${NO_COLOR}"
;;
5)caddy -service restart
echo -e "${GREEN}caddy服务启动${NO_COLOR}"
;;
0) exit
;;
*)echo -e "${RED}输入错误!!!${NO_COLOR}"
exit
;;
esac
fi
#=========安装的trojan+nginx+tls一键脚本===============================
if [ -e "/usr/sbin/nginx" -a -e "/usr/local/bin/trojan" ]; then
echo -e "
$FUCHSIA===================================================
${GREEN}系统检测到您目前安装的是trojan+nginx+tls一键脚本
$FUCHSIA===================================================
${GREEN}1. 停止trojan ${GREEN}2. 重启trojan
$FUCHSIA===================================================
${GREEN}3. 修改trojan密码 ${GREEN}4. 停止nginx
$FUCHSIA===================================================
${GREEN}5. 重启nginx ${GREEN}0. 啥也不做,退出
$FUCHSIA===================================================${NO_COLOR}"
read -p "请输入您要执行的操作的数字:" aNum
case $aNum in
1)systemctl stop trojan
echo -e "${GREEN}trojan服务停止${NO_COLOR}"
;;
2)systemctl restart trojan
echo -e "${GREEN}trojan服务启动${NO_COLOR}"
;;
3)if [ -f "/usr/local/etc/trojan/config.json" ]; then
password=`sed -n "1p" /usr/local/etc/trojan/trojan_info`
rm -f /var/www/${password}.html
rm -f /var/www/${password}.png
read -p "新密码:" password
fl="no"
while [[ $fl = "no" ]]; do
read -p "密码只能是字母和数字的组合:" password
for ((i=0;$i<${#password};i++));
do
str=${password:$i:1};
case "$str" in
[a-z]|[A-Z]|[0-9])fl="yes"
;;
*)echo "密码中含非法字符"
fl="no"
break
;;
esac
done
done
while [ "${password}" = "" ]; do
read -p "密码不能为空,请重新输入:" password
done
sed -i "8c \"$password\"," /usr/local/etc/trojan/config.json
domainname=`sed -n "2p" /usr/local/etc/trojan/trojan_info`
vps=`sed -n "3p" /usr/local/etc/trojan/trojan_info`
code="trojan://${password}@${domainname}:443"
qrencode -o /var/www/${password}.png -s 8 "${code}"
wget --no-check-certificate -O /var/www/trojan_tmpl.html https://raw.githubusercontent.com/JeannieStudio/all_install/master/trojan_tmpl.html
chmod +x /var/www/trojan_tmpl.html
end_time=$(echo | openssl s_client -servername $domainname -connect $domainname:443 2>/dev/null | openssl x509 -noout -dates |grep 'After'| awk -F '=' '{print $2}'| awk -F ' +' '{print $1,$2,$4 }' )
end_times=$(date +%s -d "$end_time")
now_time=$(date +%s -d "$(date | awk -F ' +' '{print $2,$3,$6}')")
RST=$(($((end_times-now_time))/(60*60*24)))
eval "cat <<EOF
$(< /var/www/trojan_tmpl.html)
EOF
" > /var/www/${password}.html
systemctl stop trojan
systemctl start trojan
sed -i "1c ${password}" /usr/local/etc/trojan/trojan_info
sed -i "/详情:https:/c 详情:https://${domainname}/${password}.html " /etc/motd
echo -e "${GREEN}恭喜你,密码修改成功,详情:https://${domainname}/${password}.html${NO_COLOR}"
else
echo -e "${RED}很遗憾,Trojan配置文件不存在${NO_COLOR}"
fi
systemctl start trojan
;;
4)nginx -s stop
echo -e "${GREEN}nginx服务停止${NO_COLOR}"
;;
5)nginx
echo -e "${GREEN}nginx服务启动${NO_COLOR}"
;;
0) exit
;;
*)echo -e "${RED}输入错误!!!${NO_COLOR}"
exit
;;
esac
fi
#=========安装的v2ray+caddy+tls一键脚本==============================
if [ -e "/usr/local/bin/caddy" -a -e "/usr/bin/v2ray/v2ray" ]; then
echo -e "
$FUCHSIA===================================================
${GREEN}系统检测到您目前安装的是v2ray+caddy+tls一键脚本
$FUCHSIA===================================================
${GREEN}1. 停止v2ray ${GREEN}2. 重启v2ray
$FUCHSIA===================================================
${GREEN}3. 修改UUID ${GREEN}4. 停止caddy
$FUCHSIA===================================================
${GREEN}5. 重启caddy ${GREEN}0. 啥也不做,退出
$FUCHSIA===================================================${NO_COLOR}"
read -p "请输入您要执行的操作的数字:" aNum
case $aNum in
1)service v2ray stop
echo -e "${GREEN}v2ray服务停止${NO_COLOR}"
;;
2)service v2ray restart
echo -e "${GREEN}v2ray服务启动${NO_COLOR}"
;;
3)if [ -f "/etc/v2ray/config.json" ]; then
id=`sed -n "1p" /etc/v2ray/v2ray_info`
rm -f /var/www/${id}.html
rm -f /var/www/$id.png
rm -f code_config.json
genId
domainname=`sed -n "2p" /etc/v2ray/v2ray_info`
vps=`sed -n "3p" /etc/v2ray/v2ray_info`
read -p "已帮您随机产生一个uuid:
$id,
满意吗?(输入y表示不满意再生成一个,按其他键表示接受)" answer
while [[ "$answer" = "y" ]]; do
genId
read -p "uuid:$id,满意吗?(不满意输入y,按其他键表示接受)" answer
done
curl -s -o code_config.json https://raw.githubusercontent.com/JeannieStudio/jeannie/master/config.json
sed -i "s/"b831381d-6324-4d53-ad4f-8cda48b30811"/$id/g" code_config.json
\cp -rf code_config.json /etc/v2ray/config.json
sed -i '/"network": "ws",/i "security": "tls",' code_config.json
wget --no-check-certificate -O json2vmess.py https://raw.githubusercontent.com/JeannieStudio/all_install/master/json2vmess.py
chmod +x json2vmess.py
code=$(./json2vmess.py --addr ${domainname} --filter ws --amend port:443 code_config.json)
qrencode -o /var/www/$id.png -s 8 "${code}"
end_time=$(echo | openssl s_client -servername $domainname -connect $domainname:443 2>/dev/null | openssl x509 -noout -dates |grep 'After'| awk -F '=' '{print $2}'| awk -F ' +' '{print $1,$2,$4 }' )
end_times=$(date +%s -d "$end_time")
now_time=$(date +%s -d "$(date | awk -F ' +' '{print $2,$3,$6}')")
RST=$(($((end_times-now_time))/(60*60*24)))
eval "cat <<EOF
$(< /var/www/v2ray_tmpl.html)
EOF
" > /var/www/${id}.html
sed -i "/详情:https:/c 详情:https://${domainname}/${id}.html " /etc/motd
service v2ray stop
service v2ray start
sed -i "1c ${id}" /etc/v2ray/v2ray_info
echo -e "${GREEN}恭喜你,UUID修改成功,详情:https://${domainname}/${id}.html ${NO_COLOR}"
else
echo -e "${RED}很遗憾,v2ray配置文件不存在${NO_COLOR}"
fi
;;
4)caddy -service stop
echo -e "${GREEN}caddy服务停止${NO_COLOR}"
;;
5)caddy -service restart
echo -e "${GREEN}caddy服务启动${NO_COLOR}"
;;
0) exit
;;
*)echo -e "${RED}输入错误!!!${NO_COLOR}"
exit
;;
esac
fi
#=========安装的v2ray+nginx+tls一键脚本==============================
if [ -e "/usr/sbin/nginx" -a -e "/usr/bin/v2ray/v2ray" ]; then
echo -e "
$FUCHSIA===================================================
${GREEN}系统检测到您目前安装的是v2ray+nginx+tls一键脚本
$FUCHSIA===================================================
${GREEN}1. 停止v2ray ${GREEN}2. 重启v2ray
$FUCHSIA===================================================
${GREEN}3. 修改UUID ${GREEN}4. 停止nginx
$FUCHSIA===================================================
${GREEN}5. 重启nginx ${GREEN}0. 啥也不做,退出
$FUCHSIA===================================================${NO_COLOR}"
read -p "请输入您要执行的操作的数字:" aNum
case $aNum in
1)service v2ray stop
echo -e "${GREEN}v2ray服务停止${NO_COLOR}"
;;
2)service v2ray restart
echo -e "${GREEN}v2ray服务启动${NO_COLOR}"
;;
3)if [ -f "/etc/v2ray/config.json" ]; then
id=`sed -n "1p" /etc/v2ray/v2ray_info`
rm -f /var/www/${id}.html
rm -f /var/www/$id.png
rm -f code_config.json
genId
domainname=`sed -n "2p" /etc/v2ray/v2ray_info`
vps=`sed -n "3p" /etc/v2ray/v2ray_info`
read -p "已帮您随机产生一个uuid:
$id,
满意吗?(输入y表示不满意再生成一个,按其他键表示接受)" answer
while [[ "$answer" = "y" ]]; do
genId
read -p "uuid:$id,满意吗?(不满意输入y,按其他键表示接受)" answer
done
curl -s -o code_config.json https://raw.githubusercontent.com/JeannieStudio/jeannie/master/config.json
sed -i "s/"b831381d-6324-4d53-ad4f-8cda48b30811"/$id/g" code_config.json
\cp -rf code_config.json /etc/v2ray/config.json
sed -i '/"network": "ws",/i "security": "tls",' code_config.json
wget --no-check-certificate -O json2vmess.py https://raw.githubusercontent.com/JeannieStudio/all_install/master/json2vmess.py
chmod +x json2vmess.py
code=$(./json2vmess.py --addr ${domainname} --filter ws --amend port:443 code_config.json)
qrencode -o /var/www/$id.png -s 8 "${code}"
end_time=$(echo | openssl s_client -servername $domainname -connect $domainname:443 2>/dev/null | openssl x509 -noout -dates |grep 'After'| awk -F '=' '{print $2}'| awk -F ' +' '{print $1,$2,$4 }' )
end_times=$(date +%s -d "$end_time")
now_time=$(date +%s -d "$(date | awk -F ' +' '{print $2,$3,$6}')")
RST=$(($((end_times-now_time))/(60*60*24)))
eval "cat <<EOF
$(< /var/www/v2ray_tmpl.html)
EOF
" > /var/www/${id}.html
sed -i "/详情:https:/c 详情:https://${domainname}/${id}.html " /etc/motd
service v2ray stop
service v2ray start
sed -i "1c ${id}" /etc/v2ray/v2ray_info
echo -e "${GREEN}恭喜你,UUID修改成功,详情:https://${domainname}/${id}.html ${NO_COLOR}"
else
echo -e "${RED}很遗憾,v2ray配置文件不存在${NO_COLOR}"
fi
;;
4)nginx -s stop
echo -e "${GREEN}nginx服务停止${NO_COLOR}"
;;
5)nginx
echo -e "${GREEN}nginx服务启动${NO_COLOR}"
;;
0) exit
;;
*)echo -e "${RED}输入错误!!!${NO_COLOR}"
exit
;;
esac
fi
#=========安装的ssr+caddy+tls一键脚本==============================
if [ -e "/usr/local/bin/caddy" -a -d "/usr/local/shadowsocks" ]; then
echo -e "
$FUCHSIA===================================================
${GREEN}系统检测到您目前安装的是ssr+caddy+tls一键脚本
$FUCHSIA===================================================
${GREEN}1. 停止ssr ${GREEN}2. 重启ssr
$FUCHSIA===================================================
${GREEN}3. 修改密码 ${GREEN}4. 停止caddy
$FUCHSIA===================================================
${GREEN}5. 重启caddy ${GREEN}0. 啥也不做,退出
$FUCHSIA===================================================${NO_COLOR}"
read -p "请输入您要执行的操作的数字:" aNum
case $aNum in
1)/etc/init.d/shadowsocks-r stop
echo -e "${GREEN}ssr服务停止${NO_COLOR}"
;;
2)/etc/init.d/shadowsocks-r restart
echo -e "${GREEN}ssr服务启动${NO_COLOR}"
;;
3)shadowsockspwd=`sed -n "1p" /etc/shadowsocks-r/ssr_info`
shadowsockprotocol=`sed -n "2p" /etc/shadowsocks-r/ssr_info`
shadowsockscipher=`sed -n "3p" /etc/shadowsocks-r/ssr_info`
shadowsockobfs=`sed -n "4p" /etc/shadowsocks-r/ssr_info`
domainname=`sed -n "5p" /etc/shadowsocks-r/ssr_info`
vps=`sed -n "6p" /etc/shadowsocks-r/ssr_info`
rm -f /var/www/${shadowsockspwd}.html
rm -f /var/www/${shadowsockspwd}.png
read -p "请输入您要修改的密码:" shadowsockspwd
fl="no"
while [[ $fl = "no" ]]; do
read -p "密码只能是字母和数字的组合:" shadowsockspwd
# [ -z "${shadowsockspwd}" ] && shadowsockspwd="teddysun.com"
for ((i=0;$i<${#shadowsockspwd};i++));
do
str=${shadowsockspwd:$i:1};
case "$str" in
[a-z]|[A-Z]|[0-9])fl="yes"
;;
*)echo "密码中含非法字符"
fl="no"
break
;;
esac
done
done
while [ "${shadowsockspwd}" = "" ]; do
read -p "密码不能为空,请重新输入:" shadowsockspwd
done
sed -i "7c \"password\":\"$shadowsockspwd\"," /etc/shadowsocks-r/config.json
tmp1=$(echo -n "${shadowsockspwd}" | base64 -w0 | sed 's/=//g;s/\//_/g;s/+/-/g')
tmp2=$(echo -n "${domainname}:443:${shadowsockprotocol}:${shadowsockscipher}:${shadowsockobfs}:${tmp1}/?obfsparam=" | base64 -w0)
code="ssr://${tmp2}"
qrencode -o /var/www/${shadowsockspwd}.png -s 8 "${code}"
end_time=$(echo | openssl s_client -servername $domainname -connect $domainname:443 2>/dev/null | openssl x509 -noout -dates |grep 'After'| awk -F '=' '{print $2}'| awk -F ' +' '{print $1,$2,$4 }' )
end_times=$(date +%s -d "$end_time")
now_time=$(date +%s -d "$(date | awk -F ' +' '{print $2,$3,$6}')")
RST=$(($((end_times-now_time))/(60*60*24)))
eval "cat <<EOF
$(< /var/www/ssr_tmpl.html)
EOF
" > /var/www/${shadowsockspwd}.html
sed -i "1c ${shadowsockspwd}" /etc/shadowsocks-r/ssr_info
sed -i "/详情:https:/c 详情:https://${domainname}/${shadowsockspwd}.html " /etc/motd
/etc/init.d/shadowsocks-r stop
/etc/init.d/shadowsocks-r start
echo -e "${GREEN}恭喜你,密码修改成功,详情:https://${domainname}/${shadowsockspwd}.html ${NO_COLOR}"
;;
4)caddy -service stop
echo -e "${GREEN}caddy服务停止${NO_COLOR}"
;;
5)caddy -service restart
echo -e "${GREEN}caddy服务启动${NO_COLOR}"
;;
0) exit
;;
*)echo -e "${RED}输入错误!!!${NO_COLOR}"
exit
;;
esac
fi
fi
}
mgr