Spaces:
dss11
/
Paused

File size: 1,626 Bytes
a79ea2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

echo "=== 测试 HTML 文件创建逻辑 ==="

# 模拟 start.sh 中的 HTML 创建逻辑
echo "1. 测试 /var/www/html 写入..."
mkdir -p /var/www/html 2>/dev/null
chmod 755 /var/www/html 2>/dev/null || echo "无法修改 /var/www/html 权限,将使用临时目录"

if cat > /var/www/html/test.html 2>/dev/null <<'EOF'
<!DOCTYPE html>
<html><head><title>Test</title></head><body><h1>Test</h1></body></html>
EOF
then
    echo "✅ 成功写入 /var/www/html/test.html"
    WEB_ROOT="/var/www/html"
    rm -f /var/www/html/test.html
else
    echo "❌ 无法写入 /var/www/html,测试临时目录..."
    mkdir -p /tmp/www
    if cat > /tmp/www/test.html <<'EOF'
<!DOCTYPE html>
<html><head><title>Test</title></head><body><h1>Test</h1></body></html>
EOF
    then
        echo "✅ 成功写入 /tmp/www/test.html"
        WEB_ROOT="/tmp/www"
        rm -f /tmp/www/test.html
    else
        echo "❌ 无法写入任何位置"
        exit 1
    fi
fi

echo "2. 选择的 WEB_ROOT: $WEB_ROOT"

echo "3. 测试 Nginx 配置生成..."
cat > /tmp/test_nginx.conf <<EOF
worker_processes auto;
pid /tmp/nginx.pid;

events {
    worker_connections 1024;
}

http {
    server {
        listen 7860;
        root $WEB_ROOT;
        index index.html;
        
        location / {
            try_files \$uri \$uri/ =404;
        }
    }
}
EOF

if [ -f "/tmp/test_nginx.conf" ]; then
    echo "✅ Nginx 配置文件生成成功"
    echo "配置内容预览:"
    grep "root" /tmp/test_nginx.conf
    rm -f /tmp/test_nginx.conf
else
    echo "❌ Nginx 配置文件生成失败"
fi

echo "=== 测试完成 ==="