Skip to content

Commit 69d4ec3

Browse files
authored
Merge pull request #28 from gngpp/dev
feat: add launcher log status
2 parents 1041e0f + 7d34fe8 commit 69d4ec3

File tree

10 files changed

+60
-11
lines changed

10 files changed

+60
-11
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xunlei"
3-
version = "3.5.2-5"
3+
version = "3.5.2-6"
44
edition = "2021"
55
description = "Synology Nas Thunder runs on Linux"
66
license = "MIT"

openwrt/luci-app-xunlei/Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
include $(TOPDIR)/rules.mk
77

88
PKG_NAME:=luci-app-xunlei
9-
PKG_VERSION:=1.0.1
10-
PKG_RELEASE:=3
9+
PKG_VERSION:=1.0.1-4
1110

1211
PKG_MAINTAINER:=gngpp <[email protected]>
1312

openwrt/luci-app-xunlei/luasrc/controller/xunlei.lua

+21-1
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,36 @@ function index()
88
return
99
end
1010

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)
1213
page.dependent = true
1314
page.acl_depends = { "luci-app-xunlei" }
1415

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+
1519
entry({"admin", "nas", "xunlei", "status"}, call("act_status")).leaf = true
20+
entry({ "admin", "nas", "xunlei", "logtail" }, call("action_logtail")).leaf = true
1621
end
1722

1823
function act_status()
1924
local e = {}
2025
e.running = sys.call("pgrep -f xunlei >/dev/null") == 0
26+
e.application = luci.sys.exec("xunlei --version")
2127
http.prepare_content("application/json")
2228
http.write_json(e)
2329
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

openwrt/luci-app-xunlei/luasrc/model/cbi/xunlei.lua openwrt/luci-app-xunlei/luasrc/model/cbi/xunlei/client.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local m, s
22

33
m = Map("xunlei", translate("Xunlei"))
4-
m.description = translate("<a>NAS Xunlei DSM 7.x Beta Version, Invitation code (3H9F7Y6D)</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">Project GitHub URL</a>")
4+
m.description = translate("<a>NAS Xunlei DSM 7.x Beta Version</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">Project GitHub URL</a>")
55

66
m:section(SimpleSection).template = "xunlei/xunlei_status"
77

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
log = SimpleForm("logview")
2+
log.submit = false
3+
log.reset = false
4+
5+
t = log:field(DummyValue, '', '')
6+
t.rawhtml = true
7+
t.template = 'xunlei/xunlei_log'
8+
9+
return log
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<%+cbi/valueheader%>
2+
<textarea id="logview" class="cbi-input-textarea" style="width: 100%" rows="30" readonly="readonly"></textarea>
3+
4+
<script type="text/javascript">
5+
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "nas", "xunlei", "logtail")%>';
6+
XHR.poll(1, LOG_URL, null, (x, d) => {
7+
let logview = document.getElementById("logview");
8+
if (!d.running) {
9+
XHR.halt();
10+
}
11+
logview.value = d.log;
12+
logview.scrollTop = logview.scrollHeight;
13+
});
14+
</script>
15+
<%+cbi/valuefooter%>

openwrt/luci-app-xunlei/luasrc/view/xunlei/xunlei_status.htm

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
{
88
if (data.running)
99
{
10-
tb.innerHTML = '<em style=\"color:green\"><b><%:Xunlei%> <%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get xunlei.@xunlei[0].port"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
10+
tb.innerHTML = '<em style=\"color:green\"><b>' + data.application + '<%:RUNNING%></b></em>' + "<input class=\"cbi-button cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('//" + window.location.hostname + ":" + <%=luci.sys.exec("uci -q get xunlei.@xunlei[0].port"):gsub("^%s*(.-)%s*$", "%1")%> + "/')\"/>";
1111
}
1212
else
1313
{
14-
tb.innerHTML = '<em style=\"color:red\"><b><%:Xunlei%> <%:NOT RUNNING%></b></em>';
14+
tb.innerHTML = '<em style=\"color:red\"><b>' + data.application + '<%:NOT RUNNING%></b></em>';
1515
}
1616
}
1717
}

openwrt/luci-app-xunlei/po/zh-cn/xunlei.po

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ msgstr "Content-Type: text/plain; charset=UTF-8\n"
44
msgid "Xunlei"
55
msgstr "迅雷"
66

7-
msgid "<a>NAS Xunlei DSM 7.x Beta Version, Invitation code (3H9F7Y6D)</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">Project GitHub URL</a>"
8-
msgstr "<a>NAS 迅雷 DSM 7.x 内测版,邀请码(3H9F7Y6D)</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">GitHub 项目地址</a>"
7+
msgid "<a>NAS Xunlei DSM 7.x Beta Version</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">Project GitHub URL</a>"
8+
msgstr "<a>NAS 迅雷 DSM 7.x 内测版</a> | <a href=\"https://github.com/gngpp/nas-xunlei\" target=\"_blank\">GitHub 项目地址</a>"
99

1010
msgid "Enabled"
1111
msgstr "启用"
@@ -34,6 +34,12 @@ msgstr "用户名"
3434
msgid "Password"
3535
msgstr "密码"
3636

37+
msgid "Settings"
38+
msgstr "设置"
39+
40+
msgid "Log"
41+
msgstr "日志"
42+
3743
msgid "Data Storage Path"
3844
msgstr "数据储存路径"
3945

openwrt/xunlei/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=xunlei
44

5-
PKG_VERSION:=3.5.2-5
5+
PKG_VERSION:=3.5.2-6
66

77
PKG_LICENSE:=MIT
88
PKG_MAINTAINER:=gngpp <[email protected]>

openwrt/xunlei/files/xunlei.init

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ start_service() {
4444
args="$args -U $auth_user -W $auth_password"
4545
fi
4646
procd_open_instance
47-
procd_set_param command $PROG launch $args
47+
procd_set_param command /bin/sh -c "$PROG launch $args >>/var/log/xunlei.log 2>&1"
4848
procd_set_param stdout 0
4949
procd_set_param stderr 0
5050
procd_set_param pidfile /var/run/xunlei.pid

0 commit comments

Comments
 (0)