1
+ #! /data/data/com.termux/files/usr/bin/bash -e
2
+
3
+ echo -e " \033]0;NapCat安装\007"
4
+
5
+ # 前景色(普通)
6
+ red=' \033[1;31m'
7
+ magenta=' \033[0;1;35;95m'
8
+ green=' \033[1;32m'
9
+ yellow=' \033[1;33m'
10
+ blue=' \033[1;34m'
11
+ light_cyan=' \033[1;96m'
12
+
13
+ # 前景色(更亮/加粗)
14
+ red_fg_strong=' \033[1;91m'
15
+ green_fg_strong=' \033[1;92m'
16
+ yellow_fg_strong=' \033[1;93m'
17
+ blue_fg_strong=' \033[1;94m'
18
+
19
+ # 背景色
20
+ red_bg=' \033[41m'
21
+ green_bg=' \033[42m'
22
+ yellow_bg=' \033[43m'
23
+ blue_bg=' \033[44m'
24
+ light_cyan_bg=' \033[106m'
25
+
26
+ # 复位
27
+ reset=' \033[0m'
28
+
29
+
30
+ log () {
31
+ current_time=$( date +' %H:%M:%S' )
32
+ case " $1 " in
33
+ " INFO" )
34
+ echo -e " ${blue_bg} [$current_time ]${reset} ${blue_fg_strong} [信息]${reset} $2 "
35
+ ;;
36
+ " WARN" )
37
+ echo -e " ${yellow_bg} [$current_time ]${reset} ${yellow_fg_strong} [警告]${reset} $2 "
38
+ ;;
39
+ " ERROR" )
40
+ echo -e " ${red_bg} [$current_time ]${reset} ${red_fg_strong} [错误]${reset} $2 "
41
+ ;;
42
+ * )
43
+ echo -e " ${blue_bg} [$current_time ]${reset} ${blue_fg_strong} [调试]${reset} $2 "
44
+ ;;
45
+ esac
46
+ }
47
+
48
+ # 检查命令是否存在
49
+ command_exists () {
50
+ command -v " $1 " > /dev/null 2>&1
51
+ }
52
+
53
+ # 更新源到清华镜像
54
+ if ! grep -q " mirrors.tuna.tsinghua.edu.cn" " $PREFIX /etc/apt/sources.list" ; then
55
+ log " INFO" " 更新软件源到清华镜像..."
56
+ cp " $PREFIX /etc/apt/sources.list" " $PREFIX /etc/apt/sources.list.bak"
57
+ sed -i ' s@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' " $PREFIX /etc/apt/sources.list"
58
+ fi
59
+
60
+ for cmd in screen proot-distro; do
61
+ command_exists " $cmd " || pkg install -y " $cmd "
62
+ done
63
+ if [ -f " $PREFIX /etc/apt/sources.list.bak" ]; then
64
+ mv " $PREFIX /etc/apt/sources.list.bak" " $PREFIX /etc/apt/sources.list"
65
+ fi
66
+ if [ ! -d " $PREFIX /var/lib/proot-distro/installed-rootfs/debian/" ]; then
67
+ log " INFO" " 安装debian容器..."
68
+ export PD_OVERRIDE_TARBALL_URL=" https://gh-proxy.com/https://raw.githubusercontent.com/Dong-Jing-Yu/Dong-Jing-Yu.github.io/refs/heads/main/Termux/proot-distro/debian-bookworm-aarch64-pd-v4.17.3.tar.xz"
69
+ proot-distro install debian
70
+ log " INFO" " 安装完成!"
71
+ fi
72
+
73
+
74
+
75
+ init_cmd=" apt update && apt upgrade -y && \
76
+ apt install -y apt-transport-https openssl screen sudo ssh && \
77
+ service ssh start && \
78
+ sudo bash install.sh --docker n --cli n --proxy 10 && \
79
+ apt autoremove -y && \
80
+ apt clean && \
81
+ rm -rf /tmp/* /var/lib/apt/lists"
82
+ proot-distro sh debian -- bash -c " $init_cmd "
83
+
84
+ echo -e " 进入容器: ${green} proot-distro login debian${reset} \n"
0 commit comments