-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Pixman.sh
1431 lines (1230 loc) · 49.4 KB
/
Pixman.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
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
###############################
# @小白直播搭建脚本
# 项目地址:https://pixman.io/
# 最新版本:1.9.6
###############################
# 设置路径
SCRIPT_PATH="$HOME/pixman.sh" # 定义脚本路径
CONFIG_FILE="$HOME/.pixman" # 配置文件路径
# 设置默认环境变量
REVERSE_PROXY="dockerpull.com" # 设置反向代理地址
CRON_SCHEDULE="0 12 * * *" # 默认定时任务时间
PORT="52055" # 默认端口
MYTVSUPER_TOKEN="" # myTV 参数
HAMI_SESSION_ID="" # Hami 参数
HAMI_SERIAL_NO="" # Hami 参数
HAMI_SESSION_IP="" # Hami 参数
HTTP_PROXY="" # 设置代理
HTTPS_PROXY="" # 设置代理
# 设置颜色变量
RED="\033[1;31m" # 红
GREEN="\033[1;32m" # 绿
YELLOW="\033[1;33m" # 黄
CYAN="\033[1;36m" # 青
RESET="\033[0m" # 重置
# echo -e "${CYAN}这是绿色粗体文本。${RESET}"
############# 菜单 #############
# 显示 菜单
show_menu() {
echo "-------------------"
echo " @小白直播搭建工具 "
echo " 输入 y 快捷启动 "
echo "-------------------"
echo " 请选择一个项目: "
echo "-------------------"
echo "1) Pixman 项目 "
echo "2) Allinone 项目 "
echo "~~~~~~~~~~~~~~~~~~~"
echo "3) -- 工具箱 -- "
echo "~~~~~~~~~~~~~~~~~~~"
echo "4) ~~ 脚本信息 ~~ "
echo "-------------------"
echo "0) 退出 "
echo " [ Ctrl+C ] "
echo "-------------------"
}
# Pixman 菜单
show_pixman_menu() {
echo "-------------------"
echo " Pixman 菜单: "
echo "-------------------"
echo "1) 安装 Pixman 项目"
echo "2) 修改 Pixman 参数"
echo "3) 生成 Pixman 订阅"
echo "4) 转换 myTV 订阅"
echo "5) 卸载 Pixman 项目"
echo "-------------------"
echo "0) 返回主菜单 "
echo "-------------------"
}
# allinone 菜单
show_allinone_menu() {
echo "---------------------"
echo " Allinone 菜单: "
echo "---------------------"
echo "1) 安装 Allinone 项目"
echo "2) 安装 av3a 助手"
echo "3) 设置 反向代理 地址 "
echo "4) 卸载 Allinone 项目"
echo "---------------------"
echo "0) 返回主菜单 "
echo "---------------------"
}
# 工具箱 菜单
show_toolbox_menu() {
echo "----------------------"
echo " 工具箱菜单: "
echo "----------------------"
echo "1) 1Panle 面板 "
echo "2) [Docker] o11 "
echo "3) [Docker] 3X-UI "
echo "~~~~~~~~~~~~~~~~~~~~~~"
echo "5) Docker 一键清理 "
echo "----------------------"
echo "0) 返回主菜单 "
echo "----------------------"
}
# 1Panel 菜单
show_1panel_menu() {
echo "-------------------"
echo " 1Panel 菜单: "
echo "-------------------"
echo "1) 安装 1Panel "
echo "2) 卸载 1Panel "
echo "3) 设置 1Panel "
echo "-------------------"
echo "0) 返回上级菜单 "
echo "-------------------"
}
# 3X-UI 菜单
show_3x_ui_menu() {
echo "-------------------"
echo " 3X-UI 菜单: "
echo "-------------------"
echo "1) 安装 3X-UI "
echo "2) 更新 3X-UI "
echo "3) 卸载 3X-UI "
echo "-------------------"
echo "0) 返回上级菜单 "
echo "-------------------"
}
# o11 菜单
show_o11_menu() {
echo "-------------------"
echo " o11 菜单: "
echo "-------------------"
echo "1) 安装 o11 "
echo "2) 卸载 o11 "
echo "-------------------"
echo "0) 返回上级菜单 "
echo "-------------------"
}
# subs 菜单
show_subs_menu() {
echo "-------------------"
echo " Sub Store 菜单: "
echo "-------------------"
echo "1) 安装 Sub Store "
echo "2) 卸载 Sub Store "
echo "-------------------"
echo "0) 返回上级菜单 "
echo "-------------------"
}
############# Pixman #############
# 加载 Pixman 参数
load_parameters() {
if [ -e "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
else
if docker ps -a --format '{{.Names}}' | grep -q "^pixman$"; then
check_and_install_jq
extract_container_parameters
source "$CONFIG_FILE"
else
return 1
fi
fi
}
# 提取 Pixman 参数
extract_container_parameters() {
container_info=$(docker inspect "pixman")
PORT=$(echo "$container_info" | jq -r '.[0].HostConfig.PortBindings."5000/tcp"[0].HostPort // empty')
if [ -z "$PORT" ]; then
PORT=5000
fi
MYTVSUPER_TOKEN=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("MYTVSUPER_TOKEN="))' | cut -d= -f2)
HAMI_SESSION_ID=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("HAMI_SESSION_ID="))' | cut -d= -f2)
HAMI_SERIAL_NO=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("HAMI_SERIAL_NO="))' | cut -d= -f2)
HAMI_SESSION_IP=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("HAMI_SESSION_IP="))' | cut -d= -f2)
HTTP_PROXY=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("HTTP_PROXY="))' | cut -d= -f2)
HTTPS_PROXY=$(echo "$container_info" | jq -r '.[0].Config.Env[] | select(startswith("HTTPS_PROXY="))' | cut -d= -f2)
echo "PORT=$PORT" > "$CONFIG_FILE"
echo "MYTVSUPER_TOKEN=$MYTVSUPER_TOKEN" >> "$CONFIG_FILE"
echo "HAMI_SESSION_ID=$HAMI_SESSION_ID" >> "$CONFIG_FILE"
echo "HAMI_SERIAL_NO=$HAMI_SERIAL_NO" >> "$CONFIG_FILE"
echo "HAMI_SESSION_IP=$HAMI_SESSION_IP" >> "$CONFIG_FILE"
echo "HTTP_PROXY=$HTTP_PROXY" >> "$CONFIG_FILE"
echo "HTTPS_PROXY=$HTTPS_PROXY" >> "$CONFIG_FILE"
}
# 保存 Pixman 参数
save_parameters() {
{
echo "REVERSE_PROXY=$REVERSE_PROXY"
echo "SCRIPT_PATH=$SCRIPT_PATH"
[ -n "$PORT" ] && echo "PORT=$PORT"
[ -n "$CRON_SCHEDULE" ] && echo "CRON_SCHEDULE=$CRON_SCHEDULE"
[ -n "$MYTVSUPER_TOKEN" ] && echo "MYTVSUPER_TOKEN=$MYTVSUPER_TOKEN"
[ -n "$HAMI_SESSION_ID" ] && echo "HAMI_SESSION_ID=$HAMI_SESSION_ID"
[ -n "$HAMI_SERIAL_NO" ] && echo "HAMI_SERIAL_NO=$HAMI_SERIAL_NO"
[ -n "$HAMI_SESSION_IP" ] && echo "HAMI_SESSION_IP=$HAMI_SESSION_IP"
[ -n "$HTTP_PROXY" ] && echo "HTTP_PROXY=$HTTP_PROXY"
[ -n "$HTTPS_PROXY" ] && echo "HTTPS_PROXY=$HTTPS_PROXY"
} > "$CONFIG_FILE"
}
# 设置 Pixman 参数
set_parameters() {
local original_port="$PORT"
local original_token="$MYTVSUPER_TOKEN"
local original_session_id="$HAMI_SESSION_ID"
local original_serial_no="$HAMI_SERIAL_NO"
local original_session_ip="$HAMI_SESSION_IP"
local original_http_proxy="$HTTP_PROXY"
local original_https_proxy="$HTTPS_PROXY"
read -p "请输入反向代理地址 (回车跳过保持当前值: $REVERSE_PROXY): " input_reverse_proxy
[ -n "$input_reverse_proxy" ] && REVERSE_PROXY="$input_reverse_proxy"
read -p "请确认脚本路径 (回车跳过保持当前值: $SCRIPT_PATH): " input_path
[ -n "$input_path" ] && SCRIPT_PATH="$input_path"
read -p "请输入定时任务时间 (cron格式,回车跳过保持当前值: $CRON_SCHEDULE): " input_cron
[ -n "$input_cron" ] && CRON_SCHEDULE="$input_cron"
read -p "请输入端口 (回车跳过保持当前值: $PORT): " input_port
[ -n "$input_port" ] && PORT="$input_port"
read -p "请输入 MYTVSUPER_TOKEN (回车跳过保持当前值: $MYTVSUPER_TOKEN): " input_token
[ -n "$input_token" ] && MYTVSUPER_TOKEN="$input_token"
read -p "请输入 HAMI_SESSION_ID (回车跳过保持当前值: $HAMI_SESSION_ID): " input_id
[ -n "$input_id" ] && HAMI_SESSION_ID="$input_id"
read -p "请输入 HAMI_SERIAL_NO (回车跳过保持当前值: $HAMI_SERIAL_NO): " input_serial
[ -n "$input_serial" ] && HAMI_SERIAL_NO="$input_serial"
read -p "请输入 HAMI_SESSION_IP (回车跳过保持当前值: $HAMI_SESSION_IP): " input_ip
[ -n "$input_ip" ] && HAMI_SESSION_IP="$input_ip"
read -p "请输入 HTTP_PROXY (回车跳过保持当前值: $HTTP_PROXY): " input_http_proxy
[ -n "$input_http_proxy" ] && HTTP_PROXY="$input_http_proxy"
read -p "请输入 HTTPS_PROXY (回车跳过保持当前值: $HTTPS_PROXY): " input_https_proxy
[ -n "$input_https_proxy" ] && HTTPS_PROXY="$input_https_proxy"
save_parameters
if [[ "$PORT" != "$original_port" || \
"$MYTVSUPER_TOKEN" != "$original_token" || \
"$HAMI_SESSION_ID" != "$original_session_id" || \
"$HAMI_SERIAL_NO" != "$original_serial_no" || \
"$HAMI_SESSION_IP" != "$original_session_ip" || \
"$HTTP_PROXY" != "$original_http_proxy" || \
"$HTTPS_PROXY" != "$original_https_proxy" ]]; then
echo -e "${CYAN}检测到参数变化,正在卸载旧的 Pixman 容器...${RESET}"
docker rm -f pixman > /dev/null 2>&1
check_update
else
echo -e "${CYAN}参数未发生变化,无需重启 Pixman 容器${RESET}"
return 0
fi
}
# 设置 Pixman 自动更新
set_cron_job() {
(crontab -l 2>/dev/null | grep -v "$SCRIPT_PATH --auto"; echo "$CRON_SCHEDULE $SCRIPT_PATH --auto") | crontab -
}
# 判断 Pixman 容器
check_update() {
echo -e "${CYAN}检查更新...${RESET}"
IMAGE_SOURCE="pixman/pixman:latest"
PROXY_IMAGE_SOURCE="$REVERSE_PROXY/pixman/pixman:latest"
if docker ps -a --format '{{.Names}}' | grep -q "^pixman$"; then
current_image_version=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' pixman)
MODE=$(docker inspect --format='{{.HostConfig.NetworkMode}}' pixman)
if ! docker pull "$IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${CYAN}尝试使用代理...${RESET}"
if ! docker pull "$PROXY_IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${RED}安装 Pixman 失败,请检查代理或网络连接。${RESET}"
exit 1
fi
IMAGE_SOURCE="$PROXY_IMAGE_SOURCE"
fi
latest_image_version=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' "$IMAGE_SOURCE")
if [ "$current_image_version" != "$latest_image_version" ]; then
echo -e "${GREEN}发现新版本 ($latest_image_version),正在更新...${RESET}"
docker rm -f pixman > /dev/null 2>&1
docker rmi -f "$IMAGE_SOURCE" > /dev/null 2>&1
docker pull "$IMAGE_SOURCE" > /dev/null 2>&1
start_container "$IMAGE_SOURCE" "$MODE"
else
echo -e "${GREEN}当前版本 ($current_image_version),无需更新...${RESET}"
fi
else
if ! docker images --format '{{.Repository}}:{{.Tag}}' | grep -q "^pixman/pixman:latest$"; then
if ! docker pull "$IMAGE_SOURCE" > /dev/null 2>&1; then
echo "尝试使用代理..."
if ! docker pull "$PROXY_IMAGE_SOURCE" > /dev/null 2>&1; then
echo "使用代理拉取失败,请检查代理或网络连接。"
return 1
fi
latest_image_version=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' "$IMAGE_SOURCE")
echo -e "${GREEN}目前版本 ($latest_image_version),正在安装...${RESET}"
IMAGE_SOURCE="$PROXY_IMAGE_SOURCE"
fi
fi
start_container "$IMAGE_SOURCE"
fi
}
# 部署 Pixman 容器
start_container() {
local image_source="$1"
local mode="$2"
local port="${PORT:-52055}"
echo -e "${CYAN}启动 Pixman 容器...${RESET}"
if [ "$mode" != "bridge" ] && [ "$mode" != "host" ]; then
echo "请选择 Docker 模式:"
echo "1. Bridge 模式 (默认)"
echo "2. Host 模式"
read -p "输入选择 [1/2]: " user_choice
mode="bridge"
[[ "$user_choice" == "2" ]] && mode="host"
fi
if [[ "$mode" == "host" ]]; then
echo "目前使用 host 模式,默认端口: 5000。"
docker_command="docker run -d --name pixman --restart always --net=host"
else
echo "目前使用 bridge 模式,默认端口: $port 。"
docker_command="docker run -d --name pixman --restart always -p $port:5000"
fi
[ -n "$MYTVSUPER_TOKEN" ] && docker_command+=" -e MYTVSUPER_TOKEN=$MYTVSUPER_TOKEN"
[ -n "$HAMI_SESSION_ID" ] && docker_command+=" -e HAMI_SESSION_ID=$HAMI_SESSION_ID"
[ -n "$HAMI_SERIAL_NO" ] && docker_command+=" -e HAMI_SERIAL_NO=$HAMI_SERIAL_NO"
[ -n "$HAMI_SESSION_IP" ] && docker_command+=" -e HAMI_SESSION_IP=$HAMI_SESSION_IP"
[ -n "$HTTP_PROXY" ] && docker_command+=" -e HTTP_PROXY=$HTTP_PROXY"
[ -n "$HTTPS_PROXY" ] && docker_command+=" -e HTTPS_PROXY=$HTTPS_PROXY"
docker_command+=" $image_source"
eval "$docker_command"
echo -e "${GREEN}Pixman 容器已启动。${RESET}"
}
# 卸载 Pixman 项目
uninstall_pixman() {
echo "是否确定要卸载 Pixman 项目?[y/n]"
read -r -t 10 input
input=${input:-n}
if [[ "$input" =~ ^[Yy]$ ]]; then
echo -e "${CYAN}正在卸载 Pixman 项目...${RESET}"
docker stop pixman > /dev/null 2>&1
docker rm -f pixman > /dev/null 2>&1
for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'pixman/pixman'); do
docker rmi "$image" > /dev/null 2>&1
done
crontab -l | grep -v "$SCRIPT_PATH"
# rm -f "$SCRIPT_PATH"
# rm -f "$CONFIG_FILE"
# sed -i '/alias y=/d' ~/.bashrc
echo -e "${RED}Pixman 项目已成功卸载。${RESET}"
else
echo -e "${GREEN}取消卸载操作。${RESET}"
fi
}
# 生成 Pixman 订阅
live_pixman() {
local public_ip
local port
local container_id
container_id=$(docker ps -aq -f name=pixman 2>/dev/null)
if [ -z "$container_id" ]; then
echo -e "${RED}错误: Pixman 容器不存在。${RESET}"
return 1
fi
MODE=$(docker inspect --format='{{.HostConfig.NetworkMode}}' pixman)
if [[ "$MODE" == "host" ]]; then
port=5000
else
port=$(docker inspect -f '{{ (index (index .HostConfig.PortBindings "5000/tcp") 0).HostPort }}' pixman 2>/dev/null)
fi
if check_if_in_china; then
public_ip="{路由IP}"
else
public_ip=$(curl -s ifconfig.me || echo "{公网IP}")
fi
parse_cron_schedule "$CRON_SCHEDULE"
echo "■ 央视频 YSP : http://${public_ip}:${port}/ysp.m3u"
echo "■ 江苏移动魔百盒 TPTV : http://${public_ip}:${port}/tptv.m3u 或 http://${public_ip}:${port}/tptv_proxy.m3u"
echo "■ 中国移动 iTV : http://${public_ip}:${port}/itv.m3u 或 http://${public_ip}:${port}/itv_proxy.m3u"
if check_internet_connection; then
echo "■ YouTube 代理 : http://${public_ip}:${port}/youtube/{VIDEO_ID} (房间号)"
echo "■ 四季線上 4GTV : http://${public_ip}:${port}/4gtv.m3u"
if [ -n "$MYTVSUPER_TOKEN" ]; then
echo "■ MytvSuper : http://${public_ip}:${port}/mytvsuper.m3u"
fi
if [ -n "$HAMI_SESSION_ID" ] && [ -n "$HAMI_SERIAL_NO" ] && [ -n "$HAMI_SESSION_IP" ]; then
echo "■ Hami Video : http://${public_ip}:${port}/hami.m3u"
fi
fi
echo "■ Beesport : http://${public_ip}:${port}/beesport.m3u"
echo "■ TheTV : http://${public_ip}:${port}/thetv.m3u"
echo "■ DLHD : http://${public_ip}:${port}/dlhd.m3u"
echo "---------------------------------------------------------"
echo "--- Pixman 详细使用说明: https://pixman.io/topics/17 ---"
echo "--- Pixman.sh 脚本日志: https://pixman.io/topics/142 ---"
echo "---------------------------------------------------------"
read -p "按 回车键 返回 主菜单 ..."
}
# 生成 myTV 订阅
Convert_pixman() {
local public_ip
local port
local container_id
container_id=$(docker ps -aq -f name=pixman 2>/dev/null)
if [ -z "$container_id" ]; then
echo -e "${RED}错误: Pixman 容器不存在。${RESET}"
return 1
fi
if [ -n "$MYTVSUPER_TOKEN" ]; then
if ping -c 1 google.com > /dev/null 2>&1; then
MODE=$(docker inspect --format='{{.HostConfig.NetworkMode}}' pixman)
if [[ "$MODE" == "host" ]]; then
port=5000
else
port=$(docker inspect -f '{{ (index (index .HostConfig.PortBindings "5000/tcp") 0).HostPort }}' pixman 2>/dev/null)
fi
if check_if_in_china; then
public_ip="{路由IP}"
else
public_ip=$(curl -s ifconfig.me || echo "{公网IP}")
fi
echo "生成订阅中..."
docker exec pixman sh -c 'flask mytvsuper_tivimate'
echo "---------------------------------------------------------"
echo "■ MytvSuper-tivimate : http://${public_ip}:${port}/mytvsuper-tivimate.m3u"
(crontab -l; echo "0 */12 * * * /usr/bin/docker exec pixman sh -c 'flask mytvsuper_tivimate'") | crontab -
echo "■ 定时任务已设置,每 12 小时自动更新 M3U。"
else
echo -e "${RED}请查看网络环境,目前已禁用 myTV 服务。${RESET}"
return 1
fi
else
echo -e "${CYAN}MYTVSUPER_TOKEN 参数不能为空,无法生成订阅。${RESET}"
return 1
fi
echo "---------------------------------------------------------"
echo "--- Pixman 详细使用说明: https://pixman.io/topics/17 ---"
echo "--- Pixman.sh 脚本日志: https://pixman.io/topics/142 ---"
echo "---------------------------------------------------------"
read -p "按 回车键 返回 主菜单 ..."
}
############# Allinone #############
# 安装 Allinone
install_allinone() {
if docker ps -a --format '{{.Names}}' | grep -q "^allinone$"; then
echo "检测到已存在的 Allinone 容器,将进行手动更新..."
docker stop allinone > /dev/null 2>&1
docker rm allinone > /dev/null 2>&1
for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'youshandefeiyang/allinone'); do
docker rmi "$image" > /dev/null 2>&1
done
echo -e "${CYAN}已停止并删除旧的 Allinone 项目。${RESET}"
fi
echo "请选择部署方式(默认: 1):"
echo "1) 使用 host 网络模式"
echo "2) 使用 bridge 网络模式"
read -rp "输入选项 (1 或 2): " option
option=${option:-1}
local public_ip
local PORT=35455
if check_if_in_china; then
public_ip="{路由IP}"
else
public_ip=$(curl -s ifconfig.me || echo "{公网IP}")
fi
IMAGE_SOURCE="youshandefeiyang/allinone"
PROXY_IMAGE_SOURCE="$REVERSE_PROXY/youshandefeiyang/allinone"
if ! docker pull "$IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${CYAN}尝试使用代理拉取镜像...${RESET}"
if ! docker pull "$PROXY_IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${RED}安装 Allinone 失败,请检查代理或网络连接。${RESET}"
exit 1
fi
IMAGE_SOURCE="$PROXY_IMAGE_SOURCE"
fi
case $option in
1)
echo "正在使用 host 网络模式安装 Allinone..."
port=$PORT
docker run -d --restart unless-stopped --net=host --privileged=true --name allinone "$IMAGE_SOURCE"
echo -e "${GREEN}Allinone 安装完成。${RESET}"
install_watchtower "allinone"
echo "---------------------------------------------------------"
echo "■ 订阅地址:"
if check_if_in_china; then
echo "■ TV 集合 : http://$public_ip:$port/tv.m3u"
echo "■ TPTV : http://$public_ip:$port/tptv.m3u"
fi
;;
2)
echo "正在使用 bridge 网络模式安装 Allinone..."
read -rp "请输入要映射的端口 (默认: $PORT): " port
port=${port:-$PORT}
if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1024 ] || [ "$port" -gt 65535 ]; then
echo "无效端口。请使用 1024 到 65535 之间的数字。"
return 1
fi
docker run -d --restart unless-stopped --net=bridge --privileged=true -p "$port:35455" --name allinone "$IMAGE_SOURCE"
echo -e "${GREEN}Allinone 安装完成。${RESET}"
install_watchtower "allinone"
echo "---------------------------------------------------------"
echo "■ 订阅地址:"
if check_if_in_china; then
echo "■ TV 集合 : http://$public_ip:$port/tv.m3u"
echo "■ TPTV : http://$public_ip:$port/tptv.m3u"
fi
;;
*)
echo -e "${CYAN}无效选项,请选择 1 或 2。${RESET}"
return 1
;;
esac
live_allinone "$public_ip" "$port"
}
# 生成 Allinone 订阅
live_allinone() {
local public_ip="$1"
local PORT="$2"
echo "■ YY轮播 : http://${public_ip}:${PORT}/yylunbo.m3u"
echo "■ BiliBili生活 : http://${public_ip}:${PORT}/bililive.m3u"
echo "■ 虎牙一起看 : http://${public_ip}:${PORT}/huyayqk.m3u"
echo "■ 斗鱼一起看 : http://${public_ip}:${PORT}/douyuyqk.m3u"
echo "---------------------------------------------------------"
echo "■ 代理地址:"
echo "■ BiliBili 代理 : http://${public_ip}:${PORT}/bilibili/{VIDEO_ID}"
echo "■ 虎牙 代理 : http://${public_ip}:${PORT}/huya/{VIDEO_ID}"
echo "■ 斗鱼 代理 : http://${public_ip}:${PORT}/douyu/{VIDEO_ID}"
echo "■ YY 代理 : http://${public_ip}:${PORT}/yy/{VIDEO_ID}"
echo "■ 抖音 代理 : http://${public_ip}:${PORT}/douyin/{VIDEO_ID}"
echo "■ YouTube 代理 : http://${public_ip}:${PORT}/youtube/{VIDEO_ID}"
echo "---------------------------------------------------------"
echo "--- allinone 详细使用说明: https://yycx.eu.org ---"
echo "--- Pixman.sh 脚本日志: https://pixman.io/topics/142 ---"
echo "---------------------------------------------------------"
read -p "按 回车键 返回 主菜单 ..."
}
# 设置反向代理参数
proxy_allinone() {
read -p "请输入反向代理地址 (回车跳过保持当前值: $REVERSE_PROXY): " input_reverse_proxy
[ -n "$input_reverse_proxy" ] && REVERSE_PROXY="$input_reverse_proxy"
echo "反向代理地址已更新为: $REVERSE_PROXY"
save_parameters
}
# 卸载 Allinone
uninstall_allinone() {
read -p "您确定要卸载 Allinone 及删除所有相关文件吗?(y/n): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
echo "卸载操作已取消。"
return
fi
if docker ps -a | grep -q allinone; then
docker stop allinone > /dev/null 2>&1
docker rm allinone > /dev/null 2>&1
fi
if docker ps -a | grep -q av3a-assistant; then
docker stop av3a-assistant > /dev/null 2>&1
docker rm av3a-assistant > /dev/null 2>&1
fi
if [ -d "/av3a" ]; then
rm -rf /av3a
fi
for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'youshandefeiyang/allinone'); do
docker rmi "$image" > /dev/null 2>&1
done
for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'av3a-assistant'); do
docker rmi "$image" > /dev/null 2>&1
done
echo -e "${GREEN}Allinone 及其所有相关文件已完全卸载。${RESET}"
}
# 检查 Docker Compose 是否安装
install_Docker_Compose() {
if ! command -v docker-compose &> /dev/null; then
echo "Docker Compose 未安装,正在尝试安装..."
sudo curl -L "https://ghproxy.cc/https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
if ! command -v docker-compose &> /dev/null; then
echo "Docker Compose 安装失败,请手动安装。"
echo "参考资料:https://blog.csdn.net/Jimu2018/article/details/138325666"
exit 1
fi
echo -e "${GREEN}Docker Compose 安装完成。${RESET}"
else
echo -e "${GREEN}Docker Compose 已安装。${RESET}"
fi
}
# 安装 av3a
install_av3a() {
if ! check_if_in_china; then
echo -e "${RED}境外已禁止开启 av3a 服务。${RESET}"
return
fi
local public_ip="{路由IP}"
local PORT=35455
echo "若安装 av3a 助手,将固定端口,并删除 Allinone 部署,且 Docker 空间建议预留 3G 以上。"
read -p "是否继续安装 (y/n,默认 n): " CONFIRM_INSTALL
CONFIRM_INSTALL=${CONFIRM_INSTALL:-n}
if [[ "$CONFIRM_INSTALL" != "y" ]]; then
echo "安装已被终止。"
return
fi
if docker ps -a --format '{{.Names}}' | grep -q "av3a-assistant"; then
echo "av3a-assistant 容器已安装,跳过安装步骤。"
return
fi
install_Docker_Compose
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" || "$ARCH" == "amd64" ]]; then
echo "系统架构: amd64/x86_64"
INSTALL_PATH="/av3a"
generate_docker_compose "amd64" "$INSTALL_PATH"
elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then
echo "系统架构: arm64/aarch64"
INSTALL_PATH="/av3a"
generate_docker_compose "arm64" "$INSTALL_PATH"
else
echo "不支持的系统架构: $ARCH,av3a 安装失败..."
return
fi
if docker ps -a --format '{{.Names}}' | grep -q '^allinone$'; then
echo "检测到已存在的 allinone 容器,正在停止并删除..."
docker stop allinone > /dev/null 2>&1
docker rm allinone > /dev/null 2>&1
fi
if generate_docker_compose "$ARCH" "$INSTALL_PATH"; then
cd "$INSTALL_PATH"
if docker-compose up -d; then
echo "---------------------------------------------------------"
echo -e "${GREEN}Allinone 和 av3a-assistant 均已安装${RESET}"
echo "---------------------------------------------------------"
echo "■ 订阅地址:"
echo "■ TV 集合 : http://$public_ip:35442/tv.m3u (av3a)"
echo "■ TV 集合 : http://$public_ip:35455/tv.m3u (原版)"
echo "■ TPTV : http://$public_ip:35455/tptv.m3u"
live_allinone "$public_ip" "$PORT"
else
echo "启动 Docker 容器失败。"
exit 1
fi
else
echo "生成 Docker Compose 文件失败,后续操作将被终止。"
exit 1
fi
}
# 生成 Docker Compose 文件
generate_docker_compose() {
local arch=$1
local install_path=$2
mkdir -p "$install_path" || { echo "无法创建目录 $install_path"; return 1; }
if [[ "$arch" == "x86_64" || "$arch" == "amd64" ]]; then
cat <<EOF > "$install_path/docker-compose.yml"
services:
av3a-assistant:
image: ${REVERSE_PROXY}/youshandefeiyang/av3a-assistant:amd64
container_name: av3a-assistant
privileged: true
restart: unless-stopped
ports:
- "35442:35442"
networks:
- my-network
allinone:
image: ${REVERSE_PROXY}/youshandefeiyang/allinone
container_name: allinone
privileged: true
restart: unless-stopped
ports:
- "35455:35455"
networks:
- my-network
networks:
my-network:
driver: bridge
EOF
elif [[ "$arch" == "aarch64" || "$arch" == "arm64" ]]; then
cat <<EOF > "$install_path/docker-compose.yml"
services:
av3a-assistant:
image: ${REVERSE_PROXY}/youshandefeiyang/av3a-assistant:arm64
container_name: av3a-assistant
privileged: true
restart: unless-stopped
ports:
- "35442:35442"
networks:
- my-network
allinone:
image: ${REVERSE_PROXY}/youshandefeiyang/allinone
container_name: allinone
privileged: true
restart: unless-stopped
ports:
- "35455:35455"
networks:
- my-network
networks:
my-network:
driver: bridge
EOF
else
echo "不支持的系统架构: $arch"
return 1
fi
}
############# watchtower #############
# 设置 watchtower 任务
install_watchtower() {
local name=$1
if [ "$(docker ps -q -f name=watchtower)" ]; then
existing_args=$(docker inspect --format '{{.Args}}' watchtower)
monitored_containers=$(echo "$existing_args" | grep -oP '(\w+)' | tr '\n' ' ')
if echo "$monitored_containers" | grep -qw "$name"; then
echo "---------------------------------------------------------"
echo -e "${CYAN}■ 服务器将于每天凌晨五点,进行检测更新。${RESET}"
return
fi
monitored_containers+="$name"
docker stop watchtower > /dev/null 2>&1
docker rm watchtower > /dev/null 2>&1
else
monitored_containers="$name"
fi
echo "正在安装或配置 Watchtower 并监控 $name 镜像更新..."
IMAGE_SOURCE="containrrr/watchtower"
PROXY_IMAGE_SOURCE="$REVERSE_PROXY/containrrr/watchtower"
if ! docker pull "$IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${CYAN}尝试使用代理拉取镜像...${RESET}"
if ! docker pull "$PROXY_IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${RED}安装 watchtower 失败,请检查代理或网络连接。${RESET}"
return
fi
IMAGE_SOURCE="$PROXY_IMAGE_SOURCE"
fi
docker run -d --name watchtower --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock "$IMAGE_SOURCE" $monitored_containers -c --schedule "0 5 * * *"
echo "---------------------------------------------------------"
echo -e "${CYAN}■ 服务器将于每天凌晨五点,进行检测更新。${RESET}"
}
# 卸载 Watchtower 监控指定容器
uninstall_watchtower() {
local name=$1
if [ "$(docker ps -q -f name=watchtower)" ]; then
echo "正在检查 Watchtower 监控的容器..."
existing_args=$(docker inspect --format '{{.Args}}' watchtower)
monitored_containers=$(echo "$existing_args" | grep -oP '(\w+)' | tr '\n' ' ')
if echo "$monitored_containers" | grep -qw "$name"; then
monitored_containers=$(echo "$monitored_containers" | sed "s/\b$name\b//g")
if [ -z "$monitored_containers" ]; then
echo "没有其他监控的容器,正在停止并删除 Watchtower..."
docker stop watchtower > /dev/null 2>&1
docker rm watchtower > /dev/null 2>&1
for image in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'containrrr/watchtower'); do
docker rmi "$image" > /dev/null 2>&1
done
echo "Watchtower 已成功卸载。"
else
docker stop watchtower > /dev/null 2>&1
docker rm watchtower > /dev/null 2>&1
echo "正在更新 Watchtower,仅监控剩余容器..."
IMAGE_SOURCE="containrrr/watchtower"
PROXY_IMAGE_SOURCE="$REVERSE_PROXY/containrrr/watchtower"
if ! docker pull "$IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${CYAN}尝试使用代理拉取镜像...${RESET}"
if ! docker pull "$PROXY_IMAGE_SOURCE" > /dev/null 2>&1; then
echo -e "${RED}安装 watchtower 失败,请检查代理或网络连接。${RESET}"
return
fi
IMAGE_SOURCE="$PROXY_IMAGE_SOURCE"
fi
docker run -d --name watchtower --restart unless-stopped -v /var/run/docker.sock:/var/run/docker.sock "$IMAGE_SOURCE" $monitored_containers -c --schedule "0 5 * * *"
echo "· "$name" 容器已从监控中删除。"
fi
else
echo "容器 $name 未被 Watchtower 监控。"
fi
else
echo "Watchtower 当前未安装。"
fi
}
############# 3X-UI #############
# 安装 3X-UI
install_3x_ui() {
echo "请选择部署方式:"
echo "1) 使用 host 网络模式 (添加节点方便)"
echo "2) 使用 bridge 网络模式 (添加节点,需映射端口)"
echo "3) 使用 sh 脚本 直接安装 (推荐)"
read -rp "输入选项 (1-3): " option
if check_if_in_china; then
local public_ip="{路由IP}"
else
local public_ip=$(curl -s ifconfig.me || echo "{公网IP}")
fi
case $option in
1)
echo "正在使用 host 网络模式安装 3X-UI 面板..."
docker run -d \
-e XRAY_VMESS_AEAD_FORCED=false \
-v "$PWD/db/:/etc/x-ui/" \
-v "$PWD/cert/:/root/cert/" \
--network=host \
--restart=unless-stopped \
--name 3x-ui \
ghcr.io/mhsanaei/3x-ui:latest
echo -e "${GREEN}3X-UI 安装完成。${RESET}"
echo "访问信息:"
echo "URL: http://$public_ip:2053"
;;
2)
echo "正在使用 bridge 网络模式安装 3X-UI 面板..."
local default_port=17878
read -rp "请输入要映射的端口 (默认: $default_port): " port
port=${port:-$default_port}
if ! [[ "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1024 ] || [ "$port" -gt 65535 ]; then
echo "无效端口。请使用 1024 到 65535 之间的数字。"
return 1
fi
local node_port1=$(generate_random_port)
local node_port2=$(generate_random_port)
local node_port3=$(generate_random_port)
docker run -d \
-e XRAY_VMESS_AEAD_FORCED=false \
-p $port:2053 \
-p $node_port1:$node_port1 \
-p $node_port2:$node_port2 \
-v "$PWD/db/:/etc/x-ui/" \
-v "$PWD/cert/:/root/cert/" \
--restart=unless-stopped \
--name 3x-ui \
ghcr.io/mhsanaei/3x-ui:latest
echo -e "${GREEN}3X-UI 安装完成。${RESET}"
echo "访问信息:"
echo "URL: http://$public_ip:$port"
echo "随机生成两个节点端口,后续自行添加。"
echo "节点端口: $node_port1"
echo "节点端口: $node_port2"
echo "节点端口: $node_port3"
;;
3)
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)
echo -e "${GREEN}3X-UI 安装完成。${RESET}"
echo "访问信息:"
echo "输入 x-ui 进行修改设置"
echo "URL: http://$public_ip:2053"
;;
*) echo "无效的选项,请输入 0-3。" ;;
esac
echo "------------------"
echo "默认用户名: admin"
echo "默认密码: admin"
echo "------------------"
echo "请立即更改默认密码!"
echo "------------------"
echo "GIthub: https://github.com/MHSanaei/3x-ui"
echo "------------------"
read -p "按 回车键 返回 主菜单 ..."
}
# 更新 3X-UI
update_3x_ui() {
echo "正在更新 3X-UI 面板至最新版本..."
if docker ps -a | grep -q 3x-ui; then
docker stop 3x-ui > /dev/null 2>&1
docker rm 3x-ui > /dev/null 2>&1
install_3x_ui
echo "3X-UI 面板已更新至最新版本。"
else
echo "错误:未找到 3x-ui 容器。请先安装 3X-UI。"
return 1
fi
}