@@ -8,16 +8,36 @@ function index()
8
8
return
9
9
end
10
10
11
- local page = entry ({" admin" , " nas" , " xunlei" }, cbi (" xunlei" ), _ (" Xunlei" ), 100 )
11
+ local page
12
+ page = entry ({ " admin" , " nas" , " xunlei" }, alias (" admin" , " nas" , " xunlei" , " client" ), _ (" Xunlei" ), 10 )
12
13
page .dependent = true
13
14
page .acl_depends = { " luci-app-xunlei" }
14
15
16
+ entry ({ " admin" , " nas" , " xunlei" , " client" }, cbi (" xunlei/client" ), _ (" Settings" ), 10 ).leaf = true
17
+ entry ({ " admin" , " nas" , " xunlei" , " log" }, form (" xunlei/log" ), _ (" Log" ), 30 ).leaf = true
18
+
15
19
entry ({" admin" , " nas" , " xunlei" , " status" }, call (" act_status" )).leaf = true
20
+ entry ({ " admin" , " nas" , " xunlei" , " logtail" }, call (" action_logtail" )).leaf = true
16
21
end
17
22
18
23
function act_status ()
19
24
local e = {}
20
25
e .running = sys .call (" pgrep -f xunlei >/dev/null" ) == 0
26
+ e .application = luci .sys .exec (" xunlei --version" )
21
27
http .prepare_content (" application/json" )
22
28
http .write_json (e )
23
29
end
30
+
31
+ function action_logtail ()
32
+ local fs = require " nixio.fs"
33
+ local log_path = " /var/log/xunlei.log"
34
+ local e = {}
35
+ e .running = luci .sys .call (" pidof xunlei >/dev/null" ) == 0
36
+ if fs .access (log_path ) then
37
+ e .log = luci .sys .exec (" tail -n 100 %s | sed 's/\\ x1b\\ [[0-9;]*m//g'" % log_path )
38
+ else
39
+ e .log = " "
40
+ end
41
+ luci .http .prepare_content (" application/json" )
42
+ luci .http .write_json (e )
43
+ end
0 commit comments