-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCLIProxyAPI.conf
More file actions
62 lines (50 loc) · 2.12 KB
/
CLIProxyAPI.conf
File metadata and controls
62 lines (50 loc) · 2.12 KB
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
# --- 基础信息 / Basic Information ---
local app_id="CLIProxyAPI" # 注意:原为 CLIProxyAPI,此处已按您的代码调整为 cripoxyapi
local app_name="CLIProxyAPI"
local app_text="将 Gemini、Claude、Codex、Qwen 等免费模型包装成 OpenAI 兼容 API 服务"
local app_url="https://github.com/router-for-me/CLIProxyAPI"
local docker_name="cli-proxy-api"
local docker_port="8317"
local app_size="1"
# --- 核心逻辑 / Core Logic ---
docker_app_install() {
# 必须在 /home/docker/ 下创建应用目录
mkdir -p /home/docker/CLIProxyAPI && cd /home/docker/CLIProxyAPI
# 下载仓库(推荐使用 gh_proxy 加速国内访问)
git clone "${gh_proxy}github.com/router-for-me/CLIProxyAPI.git" . || {
echo "克隆仓库失败,请检查网络或 gh_proxy 设置"
return 1
}
# 准备配置文件(必须)
cp config.example.yaml config.yaml
cp .env.example .env
read -s -p "请输入管理密钥: " KEY
echo
sed -i -E '
s/^(\s*)allow-remote:\s*false\s*$/\1allow-remote: true/
s/^(\s*)secret-key:\s*""\s*$/\1secret-key: "'"$KEY"'"/
' config.yaml
# 端口处理(使用变量,便于用户自定义)
sed -i "s/8317:8317/${docker_port}:8317/g" docker-compose.yml 2>/dev/null || true
# 启动服务(使用官方预构建镜像,推荐)
docker compose up -d
check_docker_app_ip
echo "访问地址请带上/management.html WebUI访问路径格式 http://127.0.0.1:8317/management.html "
}
docker_app_update() {
cd /home/docker/CLIProxyAPI || { echo "目录不存在"; return 1; }
git pull "${gh_proxy}github.com/router-for-me/CLIProxyAPI.git" main
docker compose pull
docker compose up -d
echo "更新完成"
}
docker_app_uninstall() {
cd /home/docker/CLIProxyAPI || { echo "目录不存在"; return 1; }
# 停止并删除容器、网络、卷(--volumes 可选,如果想彻底清除 token)
docker compose down --rmi all --volumes
# 彻底物理删除目录
cd .. && rm -rf CLIProxyAPI
echo "卸载完成"
}
# --- 注册 (必须包含) / Registration (Mandatory) ---
docker_app_plus