small-package/luci-app-socat/luasrc/controller/socat.lua

22 lines
837 B
Lua
Raw Normal View History

2021-09-24 23:37:27 +08:00
-- Copyright 2020 Lienol <lawlienol@gmail.com>
module("luci.controller.socat", package.seeall)
function index()
2022-04-01 20:21:10 +08:00
if not nixio.fs.access("/etc/config/socat") then
return
end
2021-09-24 23:37:27 +08:00
2022-04-01 20:21:10 +08:00
entry({"admin", "network", "socat"}, alias("admin", "network", "socat", "index"), _("Socat"), 100).dependent = true
entry({"admin", "network", "socat", "index"}, cbi("socat/index")).leaf = true
entry({"admin", "network", "socat", "config"}, cbi("socat/config")).leaf = true
entry({"admin", "network", "socat", "status"}, call("act_status")).leaf = true
2021-09-24 23:37:27 +08:00
end
2022-04-01 20:21:10 +08:00
function act_status()
local e = {}
e.index = luci.http.formvalue("index")
2022-08-09 20:22:33 +08:00
e.status = luci.sys.call(string.format("busybox ps -w | grep -v 'grep' | grep '/var/etc/socat/%s' >/dev/null", luci.http.formvalue("id"))) == 0
2022-04-01 20:21:10 +08:00
luci.http.prepare_content("application/json")
luci.http.write_json(e)
2021-09-24 23:37:27 +08:00
end