lgq
2025-05-26 0e3ba084acf8e7b880a19ef6107d77a8cab1f83a
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
#!/bin/sh
# 端口配置-保存
#
export PATH=/sbin:/usr/sbin:$PATH
echo -en "Content-type: text/html; charset=utf-8\n\n"
#*****************************************************
source ../bin/env.sh
db="../bin/db"
jsoner="../bin/jsoner"
 
 
file="/tmp/fzzy_upgrade"
 
timeout=50
start_time=$(date +%s)
 
file_found=0
 
while true;do
 
    current_time=$(date +%s)
    elapsed=$((current_time - start_time))
 
    # 总超时判断
    if [ $elapsed -ge $timeout ]; then
    rm $file
        echo "{\"code\":\"error\"}"
        break
    fi
 
    # 第一阶段:前5秒检测文件存在性
    if [ $file_found -eq 0 ]; then
        if [ $elapsed -le 5 ]; then
            if [ -f "$file" ]; then
                file_found=1
            else
                sleep 0.2
                continue
            fi
        else
        rm $file
            echo "{\"code\":\"error\"}"
            break
        fi
    fi
 
    # 第二阶段:检测文件内容
    content=$(cat "$file" 2>/dev/null)
    if [ "$content" = "success" ]; then
    rm $file
        echo "{\"code\":\"success\"}"
        break
    fi
 
    sleep 0.2
done
 
rm $file