-
Notifications
You must be signed in to change notification settings - Fork 0
/
fan_node_2.sh
executable file
·57 lines (49 loc) · 1.33 KB
/
fan_node_2.sh
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
#!/bin/bash
# 检查是否提供了正确的参数
if [ $# -ne 1 ]; then
echo "Usage: $0 <duty_cycle>"
exit 1
fi
# 提取转速参数
duty_cycle=$1
# 变量定义
host="https://10.123.64.22"
cookie="lang=zh-tw; QSESSIONID=d16c449ea52f36f7e14xYYkNNcaSp7Y7; refresh_disable=1"
csrf_token="kl2YVRJA"
if [ "$duty_cycle" = "auto" ]; then
curl "$host/api/settings/fans-mode" \
-X 'PUT' \
-H 'Accept: */*' \
-H 'Content-Type: application/json' \
-H "Cookie: $cookie" \
-H "Origin: $host" \
-H "X-CSRFTOKEN: $csrf_token" \
-H "X-Requested-With: XMLHttpRequest" \
--data-raw '{"control_mode":"auto"}' \
--insecure
else
curl "$host/api/settings/fans-mode" \
-X 'PUT' \
-H 'Accept: */*' \
-H 'Content-Type: application/json' \
-H "Cookie: $cookie" \
-H "Origin: $host" \
-H "X-CSRFTOKEN: $csrf_token" \
-H "X-Requested-With: XMLHttpRequest" \
--data-raw '{"control_mode":"manual"}' \
--insecure
# 遍历控制每个风扇
for ((i=1; i<=12; i++)); do
curl "$host/api/settings/fan/$i" \
-X 'PUT' \
-H 'Accept: */*' \
-H 'Content-Type: application/json' \
-H "Cookie: $cookie" \
-H "Origin: $host" \
-H "X-CSRFTOKEN: $csrf_token" \
-H "X-Requested-With: XMLHttpRequest" \
--data-raw "{\"duty\":$duty_cycle}" \
--insecure &
done
fi
echo "Done"