-
Notifications
You must be signed in to change notification settings - Fork 114
/
lang1.sh
904 lines (868 loc) · 27 KB
/
lang1.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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
#!/usr/bin/env bash
#====================================================
# System Request:Ubuntu 18.04+/20.04+
# Author: dahuilang
# Dscription: qinglong onekey Management
# github: https://github.com/shidahuilang
#====================================================
# 字体颜色配置
Green="\033[32;1m"
Red="\033[31;1m"
Yellow="\033[33;1m"
Blue="\033[36;1m"
Font="\033[0m"
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
OK="${Green}[OK]${Font}"
ERROR="${Red}[ERROR]${Font}"
function print_ok() {
echo
echo -e " ${OK} ${Blue} $1 ${Font}"
echo
}
function print_error() {
echo
echo -e "${ERROR} ${RedBG} $1 ${Font}"
echo
}
function ECHOY() {
echo
echo -e "${Yellow} $1 ${Font}"
echo
}
function ECHOB() {
echo
echo -e "${Blue} $1 ${Font}"
}
function ECHOG() {
echo
echo -e "${Green} $1 ${Font}"
echo
}
function ECHOR() {
echo
echo -e "${Red} $1 ${Font}"
echo
}
function ECHOYY() {
echo -e "${Yellow} $1 ${Font}"
}
function ECHOGG() {
echo -e "${Green} $1 ${Font}"
}
function ECHORR() {
echo -e "${Red} $1 ${Font}"
}
judge() {
if [[ 0 -eq $? ]]; then
echo
print_ok "$1 完成"
echo
sleep 1
else
echo
print_error "$1 失败"
echo
exit 1
fi
}
if [[ ! "$USER" == "root" ]]; then
print_error "警告:请使用root用户操作!~~"
exit 1
fi
export Current="$PWD"
function qinglong_port() {
clear
echo
ECHOY " 请选择网络类型"
ECHOB " 1. bridge [默认类型]"
ECHOB " 2. host [一般为openwrt旁路由才选择的]"
echo
scqlbianma="输入您选择的编码"
while :; do
domainy=""
read -p " ${scqlbianma}: " SCQL
case $SCQL in
1)
export QING_PORT="YES"
break
;;
2)
export QING_PORT="NO"
break
;;
*)
scqlbianma="请输入正确的编码"
;;
esac
done
export local_ip="$(curl -sS --connect-timeout 10 -m 60 https://ip.3322.net)"
export YUMING="请输入您当前服务器的IP[比如:${local_ip}]"
echo
echo
while :; do
read -p " ${YUMING}:" IP
if [[ -n "${IP}" ]] && [[ "$(echo ${IP} |grep -c '.*\..*\..*\..*')" == '1' ]]; then
domainy="Y"
fi
case $domainy in
Y)
export IP="${IP}"
break
;;
*)
export YUMING="敬告:请输入正确的IP"
;;
esac
done
echo
if [[ "${QING_PORT}" == "YES" ]]; then
read -p " 请输入您想设置的青龙面板端口(直接回车默认:5700): " QL_PORT && printf "\n"
export QL_PORT=${QL_PORT:-"5700"}
export NETLEIXING="bridge"
export NETWORK="-p ${QL_PORT}:5700"
export YPORT="青龙面口为"
elif [[ "${QING_PORT}" == "NO" ]]; then
export QL_PORT="5700"
export YPORT="host模式默认青龙端口为"
export NETWORK="--net host"
export NETLEIXING="host"
fi
if [[ "${Api_Client}" == "true" ]]; then
read -p " maiark面板名称,可中文可英文(直接回车默认:maiark): " NVJDCNAME && printf "\n"
export NVJDCNAME=${NVJDCNAME:-"maiark"}
read -p " 请输入您想设置的maiark面板端口(直接回车默认:8082): " JDC_PORT && printf "\n"
export JDC_PORT=${JDC_PORT:-"8082"}
read -p " 请输入通过maiark面板验证最大挂机数(直接回车默认:99): " CAPACITY && printf "\n"
export CAPACITY=${CAPACITY:-"99"}
fi
ECHOGG "网络类型:${NETLEIXING}"
ECHOGG "您的IP为:${IP}"
ECHOGG "${YPORT}:${QL_PORT}"
ECHOGG "您的青龙登录地址将为:http://${IP}:${QL_PORT}"
if [[ "${Api_Client}" == "true" ]]; then
echo
ECHOYY "maiark面板名称为:${NVJDCNAME}"
ECHOYY "maiark面板端口为:${JDC_PORT}"
ECHOYY "通过maiark面板验证最大挂机数为:${CAPACITY}"
ECHOYY "您的maiark登录地址将为:http://${IP}:${JDC_PORT}"
fi
echo
read -p " 检查是否正确,正确则按回车继续,不正确输入[Q/q]回车重新输入: " NNRT
case $NNRT in
[Qq])
qinglong_port "$@"
;;
*)
print_ok "您已确认无误!"
;;
esac
}
function system_check() {
if [[ "$(. /etc/os-release && echo "$ID")" == "centos" ]]; then
ECHOG "正在安装宿主机所需要的依赖,请稍后..."
export QL_PATH="/opt"
yum -y install sudo wget git unzip net-tools.x86_64 subversion
elif [[ "$(. /etc/os-release && echo "$ID")" == "ubuntu" ]]; then
ECHOG "正在安装宿主机所需要的依赖,请稍后..."
export QL_PATH="/opt"
apt-get -y update
apt-get -y install sudo wget git unzip net-tools subversion
elif [[ "$(. /etc/os-release && echo "$ID")" == "debian" ]]; then
ECHOG "正在安装宿主机所需要的依赖,请稍后..."
export QL_PATH="/opt"
apt -y update
apt -y install sudo wget git unzip net-tools subversion
elif [[ "$(. /etc/os-release && echo "$ID")" == "alpine" ]]; then
ECHOG "正在安装宿主机所需要的依赖,请稍后..."
export QL_PATH="/opt"
apk update
apk add sudo wget git unzip net-tools subversion
elif [[ -f /etc/openwrt_release ]] && [[ -f /rom/etc/openwrt_release ]]; then
ECHOG "正在安装宿主机所需要的依赖,请稍后..."
export QL_PATH="/opt"
opkg update
opkg install git-http > /dev/null 2>&1
opkg install ca-bundle > /dev/null 2>&1
opkg install coreutils-timeout > /dev/null 2>&1
opkg install findutils-xargs > /dev/null 2>&1
opkg install unzip
XTong="openwrt"
if [[ -d /opt/docker ]]; then
export QL_PATH="/opt"
export QL_Kongjian="/opt/docker"
elif [[ -d /mnt/mmcblk2p4/docker ]]; then
export QL_PATH="/root"
export QL_Kongjian="/mnt/mmcblk2p4/docker"
else
print_error "没找到/opt/docker或者/mnt/mmcblk2p4/docker"
exit 1
fi
else
print_error "不支持您的系统"
exit 1
fi
}
function kaiqiroot_ssh() {
if [[ ! -f /etc/openwrt_release ]] && [[ ! -f /rom/etc/openwrt_release ]]; then
echo
ECHOGG "开启root用户ssh,方便使用工具连接服务器直接修改文件代码"
bash -c "$(curl -fsSL ${curlurl}/ssh.sh)"
judge "开启root用户ssh"
sleep 3
fi
}
function maiark_lj() {
export Home="$QL_PATH/maiark"
export Config="$Home/Config"
export Chromium="$Home/.local-chromium/Linux-884014"
}
function system_docker() {
if [[ "${XTong}" == "openwrt" ]]; then
if [[ ! -x "$(command -v docker)" ]]; then
print_error "没检测到docker,openwrt请自行安装docker,和挂载好硬盘"
sleep 1
exit 1
fi
else
if [[ ! -x "$(command -v docker)" ]]; then
ECHOR "没检测到docker,正在安装docker"
bash -c "$(curl -fsSL ${curlurl}/docker.sh)"
fi
fi
}
function systemctl_status() {
echo
if [[ "${XTong}" == "openwrt" ]]; then
/etc/init.d/dockerman start > /dev/null 2>&1
/etc/init.d/dockerd start > /dev/null 2>&1
sleep 3
elif [[ "$(. /etc/os-release && echo "$ID")" == "alpine" ]]; then
service docker start > /dev/null 2>&1
sleep 1
if [[ `docker version |grep -c "runc"` == '1' ]]; then
print_ok "docker正在运行中!"
else
print_error "docker没有启动,请先启动docker,或者检查一下是否安装失败"
sleep 1
exit 1
fi
else
systemctl start docker > /dev/null 2>&1
sleep 1
echo
ECHOGG "检测docker是否在运行"
if [[ `systemctl status docker |grep -c "active (running) "` == '1' ]]; then
print_ok "docker正在运行中!"
else
print_error "docker没有启动,请先启动docker,或者检查一下是否安装失败"
sleep 1
exit 1
fi
fi
}
function uninstall_qinglong() {
if [[ `docker images | grep -c "qinglong"` -ge '1' ]] || [[ `docker ps -a | grep -c "qinglong"` -ge '1' ]]; then
ECHOY "检测到青龙面板,正在卸载青龙面板,请稍后..."
docker=$(docker ps -a|grep qinglong) && dockerid=$(awk '{print $(1)}' <<<${docker})
images=$(docker images|grep qinglong) && imagesid=$(awk '{print $(3)}' <<<${images})
docker stop -t=5 "${dockerid}" > /dev/null 2>&1
docker rm "${dockerid}"
docker rmi "${imagesid}"
if [[ `docker ps -a | grep -c "qinglong"` == '0' ]]; then
print_ok "青龙面板卸载完成"
rm -rf /etc/bianliang.sh > /dev/null 2>&1
else
print_error "青龙面板卸载失败"
exit 1
fi
fi
if [[ ! -d "$QL_PATH/qlbeifen1" ]]; then
if [[ -d "$QL_PATH/ql/config" ]]; then
ECHOY "检测到 $QL_PATH 有 ql 文件夹,正在把 $QL_PATH/ql 移动到 $QL_PATH/qlbeifen 文件夹"
ECHOY "如有需要备份文件的请到 $QL_PATH/qlbeifen 文件夹查看"
rm -fr $QL_PATH/qlbeifen && mkdir -p $QL_PATH/qlbeifen
cp -r $QL_PATH/ql $QL_PATH/qlbeifen/ql > /dev/null 2>&1
cp -r $QL_PATH/qlbeifen $QL_PATH/qlbeifen1 > /dev/null 2>&1
rm -rf $QL_PATH/ql > /dev/null 2>&1
sleep 1
fi
else
rm -rf $QL_PATH/ql > /dev/null 2>&1
fi
}
function sys_kongjian() {
if [[ -f /etc/openwrt_release ]] && [[ -f /rom/etc/openwrt_release ]]; then
Available="$(df -h | grep "${QL_Kongjian}" | awk '{print $4}' | awk 'NR==1')"
FINAL=`echo ${Available: -1}`
if [[ "${FINAL}" =~ (M|K) ]]; then
print_error "敬告:可用空间小于[ ${Sys_kj}G ],不支持安装青龙${Ql_nvjdc},请挂载大点磁盘空间容量"
exit 1
fi
Overlay_Available="$(df -h | grep "${QL_Kongjian}" | awk '{print $4}' | awk 'NR==1' | sed 's/.$//g')"
Kongjian="$(awk -v num1=${Overlay_Available} -v num2=${Sys_kj} 'BEGIN{print(num1>num2)?"0":"1"}')"
ECHOY "您当前系统可用空间为${Overlay_Available}G"
if [[ "${Kongjian}" == "1" ]];then
print_error "敬告:可用空间小于[ ${Sys_kj}G ],不支持安装青龙${Ql_nvjdc},请挂载大点磁盘空间容量"
sleep 1
exit 1
fi
else
Ubunkj="$(df -h|grep -v tmpfs |grep "/dev/.*" |awk '{print $4}' |awk 'NR==1')"
FINAL=`echo ${Ubunkj: -1}`
if [[ "${FINAL}" =~ (M|K) ]]; then
print_error "敬告:可用空间小于[ ${Sys_kj}G ],不支持安装青龙${Ql_nvjdc},请加大磁盘空间容量"
sleep 1
exit 1
fi
Ubuntu_kj="$(df -h|grep -v tmpfs |grep "/dev/.*" |awk '{print $4}' |awk 'NR==1' |sed 's/.$//g')"
Kongjian="$(awk -v num1=${Ubuntu_kj} -v num2=${Sys_kj} 'BEGIN{print(num1>num2)?"0":"1"}')"
ECHOY "您当前系统可用空间为${Ubuntu_kj}G"
if [[ "${Kongjian}" == "1" ]];then
print_error "敬告:可用空间小于[ ${Sys_kj}G ],不支持安装青龙${Ql_nvjdc},请加大磁盘空间"
sleep 1
exit 1
fi
fi
}
function install_ql() {
ECHOG "正在安装青龙面板,请稍后..."
docker run -dit \
-v $QL_PATH/ql/config:/ql/config \
-v $QL_PATH/ql/log:/ql/log \
-v $QL_PATH/ql/db:/ql/db \
-v $QL_PATH/ql/scripts:/ql/scripts \
-v $QL_PATH/ql/jbot:/ql/jbot \
-v $QL_PATH/ql/deps:/ql/deps \
-v $QL_PATH/ql/raw:/ql/raw \
-v $QL_PATH/ql/jd:/ql/jd \
-v $QL_PATH/ql/repo:/ql/repo \
${NETWORK} \
--name qinglong \
--hostname qinglong \
--restart always \
whyour/qinglong:2.10.13
docker restart qinglong > /dev/null 2>&1
sleep 2
if [[ `docker ps -a | grep -c "qinglong"` == '1' ]]; then
print_ok "青龙面板安装完成"
else
print_error "青龙面板安装失败"
exit 1
fi
}
function ql_qlbeifen() {
if [[ -f ${Current}/ghproxy.sh ]]; then
docker cp ${Current}/ghproxy.sh qinglong:/ql/repo/ghproxy.sh
rm -rf ${Current}/ghproxy.sh
else
print_error "没检测到主应用变量文件,请再次尝试安装!"
exit 1
fi
if [[ -d "$QL_PATH/qlbeifen1" ]]; then
if [[ "$(grep -c JD_WSCK=\"pin= ${QL_PATH}/qlbeifen1/ql/config/env.sh)" -ge "1" ]] || [[ "$(grep -c JD_COOKIE=\"pt_key= ${QL_PATH}/qlbeifen1/ql/config/env.sh)" -ge "1" ]]; then
ECHOG "检测到您有[wskey]或者[pt_key]存在,正在还原env.sh文件(KEY文件)"
docker cp ${QL_PATH}/qlbeifen1/ql/db/env.db qinglong:/ql/db/env.db
docker cp ${QL_PATH}/qlbeifen1/ql/config/env.sh qinglong:/ql/config/env.sh
judge "还原env.sh文件"
fi
fi
}
function qinglong_dl() {
clear
echo
echo
ECHOG "青龙面板安装完成,请先登录面板再按回车,进行下一步安装程序,步骤如下:"
ECHOYY "请使用 http://${IP}:${QL_PORT} 在浏览器打开青龙面板"
ECHOB "点击[开始安装] --> [通知方式]跳过 --> 设置好[用户名]跟[密码] --> 点击[提交] --> 点击[去登录] --> 输入帐号密码完成登录!"
echo
if [[ "${Api_Client}" == "true" ]]; then
ECHOYY "登录青龙面板面板后,请在青龙面板设置好Client ID和Client Secret,设置步骤如下:"
ECHOB "系统设置 --> 应用设置 --> 添加应用 --> 名称[随意] --> 权限[全部版块都点击选上] --> 点一下新建应用空白处 --> 点击确定"
QLMEUN="请登录青龙面板后,再设置好Client ID和Client Secret,按回车继续安装脚本,或者按[ N/n ]退出安装程序"
else
QLMEUN="请登录青龙面板后,按回车继续安装脚本,或者按[ N/n ]退出安装程序"
fi
echo
while :; do
read -p " ${QLMEUN}: " MENU
S=""
if [[ "${Api_Client}" == "true" ]]; then
if [[ `docker exec -it qinglong bash -c "cat /ql/config/auth.json" | grep -c "\"token\""` -ge '1' ]] && [[ `docker exec -it qinglong bash -c "cat /ql/db/app.db" | grep -c "\"name\""` -ge '1' ]]; then
S="Y"
fi
elif [[ "${Api_Client}" == "false" ]]; then
if [[ `docker exec -it qinglong bash -c "cat /ql/config/auth.json" | grep -c "\"token\""` -ge '1' ]]; then
S="Y"
fi
fi
if [[ ${MENU} == "N" ]] || [[ ${MENU} == "n" ]]; then
S="N"
fi
case $S in
Y)
ECHOG ""
break
;;
N)
ECHOR "退出安装脚本程序!"
sleep 1
exit 1
break
;;
*)
if [[ "${Api_Client}" == "true" ]]; then
if [[ `docker exec -it qinglong bash -c "cat /ql/config/auth.json" | grep -c "\"token\""` == '0' ]] && [[ `docker exec -it qinglong bash -c "cat /ql/db/app.db" | grep -c "\"name\""` == '0' ]]; then
echo
QLMEUN="请先登录青龙面板后,再设置好Client ID和Client Secret,按回车继续安装脚本,或者按[ N/n ]退出安装程序"
elif [[ `docker exec -it qinglong bash -c "cat /ql/config/auth.json" | grep -c "\"token\""` -ge '1' ]] && [[ `docker exec -it qinglong bash -c "cat /ql/db/app.db" | grep -c "\"name\""` == '0' ]]; then
echo
QLMEUN="您已经登录青龙面板,请设置好Client ID和Client Secret,按回车继续安装脚本,或者按[ N/n ]退出安装程序"
fi
else
echo
QLMEUN="请登录青龙面板后,按回车继续安装脚本,或者按[ N/n ]退出安装程序"
fi
;;
esac
done
}
function install_rw() {
[[ ${Npm_yilai} == "true" ]] && docker exec -it qinglong bash -c "$(curl -fsSL ${curlurl}/npm.sh)"
[[ ${Npm_yilai} == "false" ]] && docker exec -it qinglong bash -c "$(curl -fsSL ${curlurl}/python3.sh)"
ECHOG "开始安装脚本,请耐心等待..."
docker exec -it qinglong bash -c "$(curl -fsSL ${curlurl}/${Sh_Path})"
}
function install_yanzheng() {
if [[ -f ${QL_PATH}/ql/config/Error ]]; then
rm -rf ${QL_PATH}/ql/config/Error
exit 1
fi
[[ -f ${QL_PATH}/qlbeifen1/ql/config/bot.json ]] && docker cp ${QL_PATH}/qlbeifen1/ql/config/bot.json qinglong:/ql/config/bot.json
[[ -d ${QL_PATH}/qlbeifen1/ql/jd ]] && docker cp ${QL_PATH}/qlbeifen1/ql/jd qinglong:/ql/
if [[ -f ${QL_PATH}/qlbeifen1/ql/scripts/rwwc ]]; then
docker cp ${QL_PATH}/qlbeifen1/ql/config/config.sh qinglong:/ql/config/config.sh
docker cp ${QL_PATH}/qlbeifen1/ql/config/config.sh qinglong:/ql/sample/config.sample.sh
fi
if [[ `ls $QL_PATH/ql/jd | grep -c ".session"` -ge '1' ]] && [[ ${wjmz} == "Aaron-lv" ]]; then
for X in $(ls -a $QL_PATH/ql/jd |egrep -o [0-9]+-[0-9]+.sh); do docker exec -it qinglong bash -c "task /ql/jd/${X}"; done
fi
rm -rf ${QL_PATH}/qlbeifen1 > /dev/null 2>&1
docker exec -it qinglong bash -c "rm -rf /ql/qlwj"
bash -c "$(curl -fsSL ${curlurl}/timesync.sh)"
echo "${QL_PATH}/ql/scripts/rwwc" > ${QL_PATH}/ql/scripts/rwwc
echo "export rwwc=${QL_PATH}/ql/scripts/rwwc" > /etc/bianliang.sh
docker restart qinglong > /dev/null 2>&1
print_ok "任务安装完成,请刷新青龙面板查看"
}
function jiance_maiark() {
if [[ `docker images | grep -c "maiark"` -ge '1' ]] || [[ `docker ps -a | grep -c "maiark"` -ge '1' ]]; then
ECHOY "检测到maiark面板,正在卸载maiark面板,请稍后..."
dockernv=$(docker ps -a|grep maiark) && dockernvid=$(awk '{print $(1)}' <<<${dockernv})
imagesnv=$(docker images|grep maiark) && imagesnvid=$(awk '{print $(3)}' <<<${imagesnv})
docker stop -t=5 "${dockernvid}" > /dev/null 2>&1
docker rm "${dockernvid}"
docker rmi "${imagesnvid}"
if [[ `docker images | grep -c "maiark"` == '0' ]]; then
print_ok "maiark面板卸载完成"
else
print_error "maiark面板卸载失败"
exit 1
fi
fi
}
function linux_maiark() {
ECHOY "maiark安装中,请稍后..."
docker run -d \
--name ${NVJDCNAME} \
--hostname maiark \
--restart always \
-v /opt/maiark:/MaiARK \
-p ${JDC_PORT}:8082 \
kissyouhunter/maiark:latest
ECHOY "您的maiark面板地址为:http://${IP}:${JDC_PORT}"
#docker restart maiark
ECHOYY "请前往opt/maiark/arkconfig.json对接青龙!"
}
function up_nvjdc() {
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock containrrr/watchtower -c --run-once maiark
exit 0
}
function OpenApi_Client() {
export MANEID="$(grep 'name' ${QL_PATH}/ql/db/app.db |awk 'END{print}' |sed -r 's/.*name\":\"(.*)\"/\1/' |cut -d "\"" -f1)"
export CLIENTID="$(grep 'client_id' ${QL_PATH}/ql/db/app.db |awk 'END{print}' |sed -r 's/.*client_id\":\"(.*)\"/\1/' |cut -d "\"" -f1)"
export CLIENTID_SECRET="$(grep 'client_secret' ${QL_PATH}/ql/db/app.db |awk 'END{print}' |sed -r 's/.*client_secret\":\"(.*)\"/\1/' |cut -d "\"" -f1)"
}
function Google_Check() {
export Google_Check=$(curl -I -s --connect-timeout 8 google.com -w %{http_code} | tail -n1)
if [ ! "$Google_Check" == 301 ];then
export curlurl="https://cdn.jsdelivr.net/gh/shidahuilang/QL-@main"
export GithubProxyUrl="https://ghproxy.com/"
ECHORR "访问谷歌失败,以下使用代理安装"
sleep 2
echo "
export curlurl="https://cdn.jsdelivr.net/gh/shidahuilang/QL-@main"
export GithubProxyUrl="https://ghproxy.com/"
" > ${Current}/ghproxy.sh
sed -i "s/^[ \t]*//g" ${Current}/ghproxy.sh
else
export curlurl="https://raw.githubusercontent.com/shidahuilang/QL-/main"
export GithubProxyUrl=""
echo "
export curlurl="https://raw.githubusercontent.com/shidahuilang/QL-/main"
export GithubProxyUrl=""
" > ${Current}/ghproxy.sh
sed -i "s/^[ \t]*//g" ${Current}/ghproxy.sh
fi
}
function config_bianliang() {
echo "
export IP="${IP}"
export QL_PATH="${QL_PATH}"
export QL_PORT="${QL_PORT}"
export JDC_PORT="${JDC_PORT}"
export QLurl="http://${IP}:${QL_PORT}"
export CAPACITY="${CAPACITY}"
export PUSHPLUS="${PUSHPLUS}"
export CLIENTID="${CLIENTID}"
export CLIENTID_SECRET="${CLIENTID_SECRET}"
export Home="${Home}"
export Config="${Config}"
export Chromium="${Chromium}"
export nvrwwc="${Home}/rwwc"
" >> /etc/bianliang.sh
sed -i "s/^[ \t]*//g" /etc/bianliang.sh
chmod +x /etc/bianliang.sh
[[ -d ${Home} ]] && echo "${Home}/rwwc" > ${Home}/rwwc
}
function aznvjdc() {
jiance_maiark
linux_maiark
config_bianliang
}
function qinglong_nvjdc() {
qinglong_port
Google_Check
system_check
kaiqiroot_ssh
maiark_lj
system_docker
systemctl_status
uninstall_qinglong
jiance_maiark
sys_kongjian
install_ql
qinglong_dl
ql_qlbeifen
OpenApi_Client
install_rw
install_yanzheng
aznvjdc
}
function azqinglong() {
qinglong_port
Google_Check
system_check
kaiqiroot_ssh
system_docker
systemctl_status
uninstall_qinglong
jiance_maiark
sys_kongjian
install_ql
qinglong_dl
ql_qlbeifen
install_rw
install_yanzheng
config_bianliang
}
memunvjdc() {
clear
echo
echo
ECHOB " 1. 升级青龙面板"
ECHOB " 2. 更新撸豆脚本库"
ECHOB " 3. 升级maiark面板"
ECHOB " 4. 重启青龙和maiark"
ECHOB " 5. 重置青龙登录错误次数和检测环境并修复"
ECHOB " 6. 卸载maiark面板"
ECHOB " 7. 卸载青龙+maiark面板"
ECHOB " 8. 进入第一主菜单(安装界面)"
ECHOB " 9. 退出程序!"
echo
scqlbianmaa="输入您选择的编码"
while :; do
read -p " ${scqlbianmaa}: " MVQLJB
case $MVQLJB in
1)
ECHOG "正在检测更新青龙面板,请耐心等候..."
docker exec -it qinglong ql update
break
;;
2)
ECHOY "正在更新任务,请耐心等候..."
docker exec -it qinglong bash -c "ql extra"
break
;;
3)
ECHOY "开始升级maiark面板,请耐心等候..."
Google_Check
up_maiark
break
;;
4)
ECHOY "重启maiark和青龙,请耐心等候..."
docker restart maiark
docker restart qinglong
sleep 5
print_ok "命令执行完成"
break
;;
5)
ECHOY "开始重置青龙登录错误次数和检测环境并修复,请耐心等候..."
docker exec -it qinglong bash -c "ql resetlet"
sleep 2
docker exec -it qinglong bash -c "ql check"
bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/shidahuilang/QL-@main/timesync.sh)"
print_ok "命令执行完成"
break
;;
6)
ECHOY " 是否卸载maiark面板?"
read -p " 是否卸载maiark面板?输入[Yy]回车确认,直接回车返回菜单:" YZJDC
case $YZJDC in
[Yy])
ECHOG " 正在卸载maiark面板"
jiance_maiark
;;
*)
memunvjdc "$@"
;;
esac
break
;;
7)
ECHOY " 是否卸载青龙+maiark面板?"
read -p " 是否卸载青龙+maiark面板?输入[Yy]回车确认,直接回车返回菜单:" YZQLNV
case $YZQLNV in
[Yy])
ECHOG "正在卸载青龙+maiark面板"
uninstall_qinglong
jiance_maiark
rm -rf /etc/bianliang.sh
;;
*)
memunvjdc "$@"
;;
esac
break
;;
8)
memu
break
;;
9)
ECHOR "您选择了退出程序!"
sleep 1
exit 1
break
;;
*)
scqlbianmaa="请输入正确的编码"
;;
esac
done
}
memuqinglong() {
clear
echo
echo
ECHOYY " 1. 升级青龙面板"
ECHOY " 2. 更新撸豆脚本库"
ECHOYY " 3. 重启青龙面板"
ECHOY " 4. 重置青龙登录错误次数和检测环境并修复"
ECHOYY " 5. 卸载青龙面板"
ECHOY " 6. 进入第一主菜单(安装界面)"
ECHOYY " 7. 退出程序!"
echo
scqlbianmaa="输入您选择的编码"
while :; do
read -p " ${scqlbianmaa}: " QLJB
case $QLJB in
1)
ECHOG "正在检测更新青龙面板,请耐心等候..."
docker exec -it qinglong ql update
break
;;
2)
ECHOY "正在更新任务,请耐心等候..."
docker exec -it qinglong bash -c "ql extra"
break
;;
3)
ECHOY "重启青龙,请耐心等候..."
docker restart qinglong
sleep 5
print_ok "命令执行完成"
break
;;
4)
ECHOY "开始重置青龙登录错误次数和检测环境并修复,请耐心等候..."
docker exec -it qinglong bash -c "ql resetlet"
sleep 2
docker exec -it qinglong bash -c "ql check"
bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/shidahuilang/QL-@main/timesync.sh)"
print_ok "命令执行完成"
break
;;
5)
ECHOB " 是否卸载青龙面板?"
echo
read -p " 是否卸载青龙面板?输入[Yy]回车确认,直接回车返回菜单:" YZQLN
case $YZQLN in
[Yy])
ECHOG "正在卸载青龙面板"
uninstall_qinglong
rm -rf /etc/bianliang.sh
;;
*)
memuqinglong "$@"
;;
esac
break
;;
6)
memu
break
;;
7)
ECHOR "您选择了退出程序!"
sleep 1
exit 1
break
;;
*)
scqlbianmaa="请输入正确的编码"
;;
esac
done
}
memuaz() {
clear
echo
echo
[[ -n "${kugonggao}" ]] && ECHOY " ${kugonggao}"
ECHOB " 1. 安装青龙+任务+依赖+maiark面板"
ECHOB " 2. 强烈推荐安装青龙+任务+maiark面板(依赖自行在青龙面板安装)"
ECHOB " 3. 安装青龙+任务+依赖"
ECHOB " 4. 安装青龙+任务(依赖自行在青龙面板安装)"
ECHOB " 5. 退出安装程序!"
echo
scqlbianmaa="输入您选择的编码"
while :; do
read -p " ${scqlbianmaa}: " QLJB
case $QLJB in
1)
export Api_Client="true"
export Npm_yilai="true"
export Sys_kj="4"
export Ql_nvjdc="和maiark面板"
ECHOG " 安装青龙+任务+依赖+maiark面板"
qinglong_nvjdc
break
;;
2)
export Api_Client="true"
export Npm_yilai="false"
export Sys_kj="4"
export Ql_nvjdc="和maiark面板"
ECHOG " 安装青龙+任务+maiark面板(依赖自行在青龙面板安装)"
qinglong_nvjdc
break
;;
3)
export Api_Client="false"
export Npm_yilai="true"
export Sys_kj="4"
export Ql_nvjdc=""
ECHOG " 安装青龙+任务+依赖"
azqinglong
break
;;
4)
export Api_Client="false"
export Npm_yilai="false"
export Sys_kj="4"
export Ql_nvjdc=""
ECHOG " 安装青龙+任务(依赖自行在青龙面板安装)"
azqinglong
break
;;
5)
ECHOR "您选择了退出程序!"
sleep 1
exit 1
break
;;
*)
scqlbianmaa="请输入正确的编码"
;;
esac
done
}
memu() {
clear
echo
echo
ECHORR "脚本适用于(ubuntu、debian、centos、alpine、openwrt)"
ECHORR "一键安装青龙,包括(docker、任务、依赖安装,一条龙服务"
ECHORR "N1或者其他晶晨系列盒子安装在[root]文件夹,其他设备都安装在[opt]文件夹内"
ECHORR "自动检测docker,有则跳过,无则安装,openwrt则请自行安装docker,如果空间太小请挂载好硬盘"
ECHORR "如果您以前安装有青龙的话,则自动删除您的青龙容器和镜像,全部推倒重新安装"
ECHORR "如果安装当前文件夹已经存在 ql 文件的话,如果您的[环境变量文件]符合要求,就会继续使用,免除重新输入KEY的烦恼"
ECHORR "maiark面板可以进行手机验证挂机,无需复杂的抓KEY,如果是外网架设的话,任何人都可以用您的maiark面板进入您的青龙挂机"
ECHORR "安装过程会有重启docker操作,如不能接受,请退出安装"
echo
ECHOY " 请选择您要安装什么类型的任务库"
ECHOB " 1. TG机器人每周提交助力码库(shufflewzc/和YYDS)库"
ECHOB " 2. 自动提交助力码库,要去库的作者那里提交资料过白名单(feverrun/my_scripts)单库"
ECHOB " 3. 退出安装程序!"
echo
scqlanmaa="输入您选择的编码"
while :; do
read -p " ${scqlanmaa}: " TGQLJB
case $TGQLJB in
1)
export wjmz="Aaron-lv"
export Sh_Path="Aaron-lv.sh"
export kugonggao="您库的选择:shufflewzc/YYDS"
memuaz
break
;;
2)
export wjmz="feverrun"
export Sh_Path="feverrun.sh"
export kugonggao="您库的选择:feverrun/my_scripts"
memuaz
break
;;
3)
ECHOR "您选择了退出程序!"
sleep 1
exit 1
break
;;
*)
scqlanmaa="请输入正确的编码"
;;
esac
done
}
[[ -f /etc/bianliang.sh ]] && source /etc/bianliang.sh
if [[ `docker images |grep -c "qinglong"` -ge '1' ]] && [[ `docker images |grep -c "maiark"` -ge '1' ]] && [[ -f ${rwwc} ]] && [[ -f ${nvrwwc} ]]; then
memunvjdc "$@"
elif [[ `docker images | grep -c "qinglong"` -ge '1' ]] && [[ -f ${rwwc} ]]; then
memuqinglong "$@"
else
memu "$@"
fi