1
+ #! /data/data/com.termux/files/usr/bin/bash -e
2
+
3
+ echo -e " \033]0;MaiBot半自动安装\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 proot-distro; do
61
+ command_exists " $cmd " || pkg install -y " $cmd "
62
+ done
63
+
64
+ if [ -f " $PREFIX /etc/apt/sources.list.bak" ]; then
65
+ mv " $PREFIX /etc/apt/sources.list.bak" " $PREFIX /etc/apt/sources.list"
66
+ fi
67
+
68
+ if [ ! -d " $PREFIX /var/lib/proot-distro/installed-rootfs/maibot/" ]; then
69
+ log " INFO" " 安装ubuntu容器..."
70
+ 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/ubuntu-noble-aarch64-pd-v4.18.0.tar.xz"
71
+ proot-distro install ubuntu --override-alias maibot
72
+ log " INFO" " 安装完成!"
73
+ fi
74
+
75
+
76
+
77
+ init_cmd=" cd ~ && \
78
+ apt update -y && \
79
+ apt install -y sudo vim git python3-dev python3.12-venv build-essential screen curl python3-pip && \
80
+ mkdir maimai && \
81
+ cd maimai && \
82
+ git clone https://gh-proxy.com/https://github.com/MaiM-with-u/MaiBot.git.git \
83
+ git clone https://gh-proxy.com/https://github.com/MaiM-with-u/MaiBot-Napcat-Adapter.git.git \
84
+ apt autoremove -y && \
85
+ apt clean && \
86
+ rm -rf /tmp/* /var/lib/apt/lists && \
87
+ pip3 install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple uv
88
+ "
89
+ proot-distro sh maibot -- bash -c " $init_cmd "
90
+
91
+ echo -e " ${red} https://docs.mai-mai.org/manual/deployment/mmc_deploy_android.html#传统方式环境配置${reset} \n"
92
+ echo -e " 脚本已执行到 ${green} 安装 uv (推荐)${reset} \n"
93
+ echo -e " 进入容器: ${green} proot-distro login nc${reset} \n"
0 commit comments