File size: 886 Bytes
af3c084
 
 
 
c4ff870
 
af3c084
 
 
5fa522d
af3c084
 
 
 
 
 
 
 
 
 
 
a1f5370
5fa522d
 
 
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
#!/bin/sh

# 1. 启动 SSH 服务
# 注意:使用绝对路径,且不需要加 -D,因为我们用 & 把它放后台
/usr/sbin/sshd -D -e 2>&1 &
echo "SSHD started on port 2222..."

# 2. 启动 Nginx
# nginx 默认会在后台运行,但这里我们用 & 确保它不阻塞后续脚本
#nginx &

# 3. 启动 Cloudflare Tunnel
if [ -z "$TUNNEL_TOKEN" ]; then
    echo "Warning: TUNNEL_TOKEN is not set. Cloudflare Tunnel will not start."
    echo "You can still access the web UI via Hugging Face port 7860."
    # 如果没有 Tunnel,我们需要一个前台进程防止容器退出
    # 这里我们让 nginx 重新到前台运行,或者直接 wait
    wait
else
    echo "Starting Cloudflare Tunnel..."
    # cloudflared 会作为前台进程运行,保持容器不退出
   nohup cloudflared tunnel --no-autoupdate run --token "$TUNNEL_TOKEN" &
fi

nginx -g "daemon off;"