mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-30 13:15:13 +08:00
💋 Sync 2026-03-30 15:17:59
This commit is contained in:
1 parent
8e2cb264ef
commit
6900a34143
6 files changed
+56
-1
No files matched your search
@@ -11,6 +11,7 @@ function index()
|
||||
page.acl_depends = { "luci-app-timewol" }
|
||||
|
||||
entry({"admin", "control", "timewol", "status"}, call("status")).leaf = true
|
||||
entry({"admin", "control", "timewol", "awake"}, call("awake")).leaf = true
|
||||
end
|
||||
|
||||
function status()
|
||||
@@ -19,3 +20,27 @@ function status()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function awake(sections)
|
||||
lan = x:get("timewol",sections,"maceth")
|
||||
mac = x:get("timewol",sections,"macaddr")
|
||||
local e = {}
|
||||
cmd = "/usr/bin/etherwake -D -i " .. lan .. " -b " .. mac .. " 2>&1"
|
||||
local p = io.popen(cmd)
|
||||
local msg = ""
|
||||
if p then
|
||||
while true do
|
||||
local l = p:read("*l")
|
||||
if l then
|
||||
if #l > 100 then l = l:sub(1, 100) .. "..." end
|
||||
msg = msg .. l
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
p:close()
|
||||
end
|
||||
e["data"] = msg
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
Reference in new issue
Block a user