ubuntu and wxedge ok
This commit is contained in:
parent
ac2d25d9bc
commit
713a9e88cd
@ -1,7 +1,7 @@
|
|||||||
local sys = require "luci.sys"
|
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
local docker = require "luci.model.docker"
|
local docker = require "luci.model.docker"
|
||||||
|
local iform = require "luci.iform"
|
||||||
|
|
||||||
module("luci.controller.ubuntu", package.seeall)
|
module("luci.controller.ubuntu", package.seeall)
|
||||||
|
|
||||||
@ -9,10 +9,6 @@ function index()
|
|||||||
|
|
||||||
entry({"admin", "services", "ubuntu"}, call("redirect_index"), _("Ubuntu"), 30).dependent = true
|
entry({"admin", "services", "ubuntu"}, call("redirect_index"), _("Ubuntu"), 30).dependent = true
|
||||||
entry({"admin", "services", "ubuntu", "pages"}, call("ubuntu_index")).leaf = true
|
entry({"admin", "services", "ubuntu", "pages"}, call("ubuntu_index")).leaf = true
|
||||||
if nixio.fs.access("/usr/lib/lua/luci/view/ubuntu/main_dev.htm") then
|
|
||||||
entry({"admin","services", "ubuntu", "dev"}, call("ubuntu_dev")).leaf = true
|
|
||||||
end
|
|
||||||
|
|
||||||
entry({"admin", "services", "ubuntu", "form"}, call("ubuntu_form"))
|
entry({"admin", "services", "ubuntu", "form"}, call("ubuntu_form"))
|
||||||
entry({"admin", "services", "ubuntu", "submit"}, call("ubuntu_submit"))
|
entry({"admin", "services", "ubuntu", "submit"}, call("ubuntu_submit"))
|
||||||
entry({"admin", "services", "ubuntu", "log"}, call("ubuntu_log"))
|
entry({"admin", "services", "ubuntu", "log"}, call("ubuntu_log"))
|
||||||
@ -31,12 +27,7 @@ function ubuntu_index()
|
|||||||
luci.template.render("ubuntu/main", {prefix=luci.dispatcher.build_url(unpack(page_index))})
|
luci.template.render("ubuntu/main", {prefix=luci.dispatcher.build_url(unpack(page_index))})
|
||||||
end
|
end
|
||||||
|
|
||||||
function ubuntu_dev()
|
|
||||||
luci.template.render("ubuntu/main_dev", {prefix=luci.dispatcher.build_url(unpack({"admin", "services", "ubuntu", "dev"}))})
|
|
||||||
end
|
|
||||||
|
|
||||||
function ubuntu_form()
|
function ubuntu_form()
|
||||||
local sys = require "luci.sys"
|
|
||||||
local error = ""
|
local error = ""
|
||||||
local scope = ""
|
local scope = ""
|
||||||
local success = 0
|
local success = 0
|
||||||
@ -207,34 +198,7 @@ function ubuntu_submit()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ubuntu_log()
|
function ubuntu_log()
|
||||||
local fs = require "nixio.fs"
|
iform.response_log("/var/log/"..appname..".log")
|
||||||
local ltn12 = require "luci.ltn12"
|
|
||||||
local logfd = io.open("/var/log/ubuntu.log", "r")
|
|
||||||
local curr = logfd:seek()
|
|
||||||
local size = logfd:seek("end")
|
|
||||||
if size > 8*1024 then
|
|
||||||
logfd:seek("end", -8*1024)
|
|
||||||
else
|
|
||||||
logfd:seek("set", curr)
|
|
||||||
end
|
|
||||||
|
|
||||||
local write_log = function()
|
|
||||||
local buffer = logfd:read(4096)
|
|
||||||
if buffer and #buffer > 0 then
|
|
||||||
return buffer
|
|
||||||
else
|
|
||||||
logfd:close()
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
http.prepare_content("text/plain;charset=utf-8")
|
|
||||||
|
|
||||||
if logfd then
|
|
||||||
ltn12.pump.all(write_log, http.write)
|
|
||||||
else
|
|
||||||
http.write("log not found" .. const_log_end)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function install_upgrade_ubuntu(req)
|
function install_upgrade_ubuntu(req)
|
||||||
@ -255,7 +219,7 @@ function install_upgrade_ubuntu(req)
|
|||||||
-- local exec_cmd = string.format("start-stop-daemon -q -S -b -x /usr/share/ubuntu/install.sh -- %s", req["$apply"])
|
-- local exec_cmd = string.format("start-stop-daemon -q -S -b -x /usr/share/ubuntu/install.sh -- %s", req["$apply"])
|
||||||
-- os.execute(exec_cmd)
|
-- os.execute(exec_cmd)
|
||||||
local exec_cmd = string.format("/usr/share/ubuntu/install.sh %s", req["$apply"])
|
local exec_cmd = string.format("/usr/share/ubuntu/install.sh %s", req["$apply"])
|
||||||
fork_exec(exec_cmd)
|
iform.fork_exec(exec_cmd)
|
||||||
|
|
||||||
local result = {
|
local result = {
|
||||||
async = true,
|
async = true,
|
||||||
@ -266,15 +230,7 @@ function install_upgrade_ubuntu(req)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function delete_ubuntu()
|
function delete_ubuntu()
|
||||||
local f = io.popen("docker rm -f ubuntu", "r")
|
local log = iform.exec_to_log("docker rm -f ubuntu")
|
||||||
local log = "docker rm -f ubuntu\n"
|
|
||||||
if f then
|
|
||||||
local output = f:read('*all')
|
|
||||||
f:close()
|
|
||||||
log = log .. output .. const_log_end
|
|
||||||
else
|
|
||||||
log = log .. "Failed" .. const_log_end
|
|
||||||
end
|
|
||||||
local result = {
|
local result = {
|
||||||
async = false,
|
async = false,
|
||||||
log = log
|
log = log
|
||||||
@ -283,15 +239,7 @@ function delete_ubuntu()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function restart_ubuntu()
|
function restart_ubuntu()
|
||||||
local f = io.popen("docker restart ubuntu", "r")
|
local log = iform.exec_to_log("docker restart ubuntu")
|
||||||
local log = "docker restart ubuntu\n"
|
|
||||||
if f then
|
|
||||||
local output = f:read('*all')
|
|
||||||
f:close()
|
|
||||||
log = log .. output .. const_log_end
|
|
||||||
else
|
|
||||||
log = log .. "Failed" .. const_log_end
|
|
||||||
end
|
|
||||||
local result = {
|
local result = {
|
||||||
async = false,
|
async = false,
|
||||||
log = log
|
log = log
|
||||||
@ -299,26 +247,3 @@ function restart_ubuntu()
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function fork_exec(command)
|
|
||||||
local pid = nixio.fork()
|
|
||||||
if pid > 0 then
|
|
||||||
return
|
|
||||||
elseif pid == 0 then
|
|
||||||
-- change to root dir
|
|
||||||
nixio.chdir("/")
|
|
||||||
|
|
||||||
-- patch stdin, out, err to /dev/null
|
|
||||||
local null = nixio.open("/dev/null", "w+")
|
|
||||||
if null then
|
|
||||||
nixio.dup(null, nixio.stderr)
|
|
||||||
nixio.dup(null, nixio.stdout)
|
|
||||||
nixio.dup(null, nixio.stdin)
|
|
||||||
if null:fileno() > 2 then
|
|
||||||
null:close()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- replace with target command
|
|
||||||
nixio.exec("/bin/sh", "-c", command)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/luci-static/ubuntu/index.js?v=<%=math.random(1,100000)%>"></script>
|
<script type="module" crossorigin src="/luci-static/iform/1.0/index.js?v=<%=math.random(1,100000)%>"></script>
|
||||||
<link rel="stylesheet" href="/luci-static/ubuntu/style.css?v=<%=math.random(1,100000)%>">
|
<link rel="stylesheet" href="/luci-static/iform/1.0/style.css?v=<%=math.random(1,100000)%>">
|
||||||
|
|
||||||
<%+footer%>
|
<%+footer%>
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
<%+header%>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
(function(){
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<div id="app">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
window.IstoreosFormEnv = {
|
|
||||||
getApi:"/cgi-bin/luci/admin/services/ubuntu/form/",
|
|
||||||
logApi:"/cgi-bin/luci/admin/services/ubuntu/log",
|
|
||||||
submitApi:"/cgi-bin/luci/admin/services/ubuntu/submit2"
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="module" src="http://127.0.0.1:8301/src/main.js"></script>
|
|
||||||
|
|
||||||
<%+footer%>
|
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
[lock-scroll=true]{overflow:hidden!important}.software-log_shade[data-v-27cc98a0],.software-log_shade *[data-v-27cc98a0]{-webkit-box-sizing:border-box;-webkit-tap-highlight-color:transparent;box-sizing:border-box;word-wrap:break-word;outline:none}.software-log_shade[data-v-27cc98a0]{width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;position:fixed;inset:0;z-index:99999}.software-log_shade .software-log_shade__bg[data-v-27cc98a0]{position:fixed;inset:0;background:rgba(68,79,83,.94) none repeat scroll 0 0!important;background-position:0 0;background-size:cover;opacity:.94}.software-log_shade .software-log_shade__pannel[data-v-27cc98a0]{width:800px;min-width:800px;border-radius:10px;z-index:100;box-shadow:3px 3px 10px #000;background:rgba(0,0,0,.9);padding:10px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-title[data-v-27cc98a0]{text-align:center;font-size:18px;color:#9f0;padding:10px;font-weight:700}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-now i[data-v-27cc98a0]{color:#fc0;font-style:normal}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content[data-v-27cc98a0]{padding:10px;width:100%;text-align:center;overflow:hidden;height:400px;overflow:overlay}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]{width:100%;border:0px solid #222;font-family:Lucida Console;font-size:11px;background:transparent;color:#fff;outline:none;overflow-x:hidden;resize:none;transition:.5s}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]:focus,.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]:hover{box-shadow:none;border-color:#fff0!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar{width:5px;height:5px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar-thumb{height:30px;outline:none;border:none;border-radius:1rem;background-color:#4c595c;-webkit-border-radius:1rem}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar-track-piece{background:none;-webkit-border-radius:0;border-radius:0}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn[data-v-27cc98a0]{width:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-27cc98a0]{visibility:visible;min-width:88px;font-weight:bolder;text-shadow:1px 1px 0px black;border-radius:8px;height:33px;font-family:Verdana,Microsoft Yahei UI,sans-serif;font-size:12px;padding:0 .7em;width:auto;min-width:122px;margin:0 10px;cursor:pointer;background:#090a0a!important;border:1px solid #fff!important;color:#fff!important;opacity:1!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-27cc98a0]:hover{opacity:.9!important}.cbi-section .title{font-size:1.1rem;line-height:1;display:block;width:100%;margin:0;color:#32325d;padding:1rem 1.25rem}.cbi-page-actions{display:inline-block;width:100%}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
|
@ -1,7 +1,8 @@
|
|||||||
local sys = require "luci.sys"
|
|
||||||
local uci = require "luci.model.uci".cursor()
|
local uci = require "luci.model.uci".cursor()
|
||||||
local util = require "luci.util"
|
local util = require "luci.util"
|
||||||
local http = require "luci.http"
|
local http = require "luci.http"
|
||||||
|
local jsonc = require "luci.jsonc"
|
||||||
|
local iform = require "luci.iform"
|
||||||
|
|
||||||
module("luci.controller.wxedge", package.seeall)
|
module("luci.controller.wxedge", package.seeall)
|
||||||
|
|
||||||
@ -28,7 +29,6 @@ function wxedge_index()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function wxedge_form()
|
function wxedge_form()
|
||||||
local sys = require "luci.sys"
|
|
||||||
local error = ""
|
local error = ""
|
||||||
local scope = ""
|
local scope = ""
|
||||||
local success = 0
|
local success = 0
|
||||||
@ -49,46 +49,63 @@ function wxedge_form()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function get_schema(data)
|
function get_schema(data)
|
||||||
local actions = {
|
local actions
|
||||||
{
|
if data.container_install then
|
||||||
name = "install",
|
actions = {
|
||||||
text = "安装",
|
{
|
||||||
type = "apply",
|
name = "restart",
|
||||||
},
|
text = "重启",
|
||||||
{
|
type = "apply",
|
||||||
name = "upgrade",
|
},
|
||||||
text = "更新",
|
{
|
||||||
type = "apply",
|
name = "upgrade",
|
||||||
},
|
text = "更新",
|
||||||
{
|
type = "apply",
|
||||||
name = "remove",
|
},
|
||||||
text = "删除",
|
{
|
||||||
type = "apply",
|
name = "remove",
|
||||||
},
|
text = "删除",
|
||||||
|
type = "apply",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
local schema = {
|
else
|
||||||
actions = actions,
|
actions = {
|
||||||
containers = get_containers(data),
|
{
|
||||||
description = "本插件能让设备快速加入网心云共享计算生态网络,为网心科技星域云贡献设备的上行带宽和存储资源,用户根据每日的贡献量可获得相应的现金收益回报。 具体请访问它的<a href=\"https://www.onethingcloud.com/\">官网</a>",
|
name = "install",
|
||||||
title = "网心云"
|
text = "安装",
|
||||||
|
type = "apply",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return schema
|
end
|
||||||
|
local schema = {
|
||||||
|
actions = actions,
|
||||||
|
containers = get_containers(data),
|
||||||
|
description = "本插件能让设备快速加入网心云共享计算生态网络,为网心科技星域云贡献设备的上行带宽和存储资源,用户根据每日的贡献量可获得相应的现金收益回报。 具体请访问它的<a href=\"https://www.onethingcloud.com/\">官网</a>",
|
||||||
|
title = "网心云"
|
||||||
|
}
|
||||||
|
return schema
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_containers(data)
|
function get_containers(data)
|
||||||
local containers = {
|
local containers = {
|
||||||
status_container(data),
|
status_container(data),
|
||||||
main_container(data)
|
main_container(data)
|
||||||
}
|
}
|
||||||
return containers
|
return containers
|
||||||
end
|
end
|
||||||
|
|
||||||
function status_container(data)
|
function status_container(data)
|
||||||
|
local status_value
|
||||||
|
if data.container_install then
|
||||||
|
status_value = "Wxedge 运行中"
|
||||||
|
else
|
||||||
|
status_value = "Wxedge 未运行"
|
||||||
|
end
|
||||||
local status_c1 = {
|
local status_c1 = {
|
||||||
labels = {
|
labels = {
|
||||||
{
|
{
|
||||||
key = "状态:",
|
key = "状态:",
|
||||||
value = "The wxedge service is not installed"
|
value = status_value
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key = "访问:",
|
key = "访问:",
|
||||||
@ -104,30 +121,45 @@ function status_container(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function main_container(data)
|
function main_container(data)
|
||||||
local main_c2 = {
|
local main_c2 = {
|
||||||
properties = {
|
properties = {
|
||||||
{
|
{
|
||||||
name = "instance1",
|
name = "instance1",
|
||||||
required = true,
|
required = true,
|
||||||
title = "实例1的存储位置:",
|
title = "实例1的存储位置:",
|
||||||
type = "string",
|
type = "string",
|
||||||
enum = {"standard", "full"},
|
enum = dup_array(data.blocks),
|
||||||
enumNames = {"Standard Version", "Full Version"}
|
enumNames = dup_array(data.blocks)
|
||||||
},
|
|
||||||
},
|
},
|
||||||
description = "请选择合适的存储位置进行安装:",
|
},
|
||||||
title = "服务操作"
|
description = "请选择合适的存储位置进行安装:",
|
||||||
}
|
title = "服务操作"
|
||||||
return main_c2
|
}
|
||||||
|
return main_c2
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_data()
|
function get_data()
|
||||||
local data = {
|
local uci = require "luci.model.uci".cursor()
|
||||||
port = "6901",
|
local default_path = ""
|
||||||
password = "password",
|
local blks = blocks()
|
||||||
version = "standard"
|
if #blks > 0 then
|
||||||
}
|
default_path = blks[1] .. "/wxedge1"
|
||||||
return data
|
end
|
||||||
|
local blk1 = {}
|
||||||
|
for _, val in pairs(blks) do
|
||||||
|
table.insert(blk1, val .. "/wxedge1")
|
||||||
|
end
|
||||||
|
|
||||||
|
local docker_path = util.exec("which docker")
|
||||||
|
local container_id = util.trim(util.exec("docker ps -aqf 'name="..appname.."'"))
|
||||||
|
local container_install = (string.len(docker_path) > 0) and (string.len(container_id) > 0)
|
||||||
|
|
||||||
|
local data = {
|
||||||
|
instance1 = uci:get_first(appname, appname, "cache_path", default_path),
|
||||||
|
blocks = blk1,
|
||||||
|
container_install = container_install
|
||||||
|
}
|
||||||
|
return data
|
||||||
end
|
end
|
||||||
|
|
||||||
function wxedge_submit()
|
function wxedge_submit()
|
||||||
@ -136,7 +168,6 @@ function wxedge_submit()
|
|||||||
local success = 0
|
local success = 0
|
||||||
local result
|
local result
|
||||||
|
|
||||||
local jsonc = require "luci.jsonc"
|
|
||||||
local json_parse = jsonc.parse
|
local json_parse = jsonc.parse
|
||||||
local content = http.content()
|
local content = http.content()
|
||||||
local req = json_parse(content)
|
local req = json_parse(content)
|
||||||
@ -160,47 +191,16 @@ function wxedge_submit()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function wxedge_log()
|
function wxedge_log()
|
||||||
local fs = require "nixio.fs"
|
iform.response_log("/var/log/"..appname..".log")
|
||||||
local ltn12 = require "luci.ltn12"
|
|
||||||
local logfd = io.open("/var/log/wxedge.log", "r")
|
|
||||||
local curr = logfd:seek()
|
|
||||||
local size = logfd:seek("end")
|
|
||||||
if size > 8*1024 then
|
|
||||||
logfd:seek("end", -8*1024)
|
|
||||||
else
|
|
||||||
logfd:seek("set", curr)
|
|
||||||
end
|
|
||||||
|
|
||||||
local write_log = function()
|
|
||||||
local buffer = logfd:read(4096)
|
|
||||||
if buffer and #buffer > 0 then
|
|
||||||
return buffer
|
|
||||||
else
|
|
||||||
logfd:close()
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
http.prepare_content("text/plain;charset=utf-8")
|
|
||||||
|
|
||||||
if logfd then
|
|
||||||
ltn12.pump.all(write_log, http.write)
|
|
||||||
else
|
|
||||||
http.write("log not found" .. const_log_end)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function install_upgrade_wxedge(req)
|
function install_upgrade_wxedge(req)
|
||||||
local password = req["password"]
|
local cache_path = req["instance1"]
|
||||||
local port = req["port"]
|
|
||||||
local version = req["version"]
|
|
||||||
|
|
||||||
-- save config
|
-- save config
|
||||||
local uci = require "luci.model.uci".cursor()
|
local uci = require "luci.model.uci".cursor()
|
||||||
uci:tset(appname, "@"..appname.."[0]", {
|
uci:tset(appname, "@"..appname.."[0]", {
|
||||||
password = password or "password",
|
cache_path = cache_path,
|
||||||
port = port or "6901",
|
|
||||||
version = version or "standard",
|
|
||||||
})
|
})
|
||||||
uci:save(appname)
|
uci:save(appname)
|
||||||
uci:commit(appname)
|
uci:commit(appname)
|
||||||
@ -208,7 +208,7 @@ function install_upgrade_wxedge(req)
|
|||||||
-- local exec_cmd = string.format("start-stop-daemon -q -S -b -x /usr/share/wxedge/install.sh -- %s", req["$apply"])
|
-- local exec_cmd = string.format("start-stop-daemon -q -S -b -x /usr/share/wxedge/install.sh -- %s", req["$apply"])
|
||||||
-- os.execute(exec_cmd)
|
-- os.execute(exec_cmd)
|
||||||
local exec_cmd = string.format("/usr/share/wxedge/install.sh %s", req["$apply"])
|
local exec_cmd = string.format("/usr/share/wxedge/install.sh %s", req["$apply"])
|
||||||
fork_exec(exec_cmd)
|
iform.fork_exec(exec_cmd)
|
||||||
|
|
||||||
local result = {
|
local result = {
|
||||||
async = true,
|
async = true,
|
||||||
@ -219,15 +219,7 @@ function install_upgrade_wxedge(req)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function delete_wxedge()
|
function delete_wxedge()
|
||||||
local f = io.popen("docker rm -f wxedge", "r")
|
local log = iform.exec_to_log("docker rm -f wxedge")
|
||||||
local log = "docker rm -f wxedge\n"
|
|
||||||
if f then
|
|
||||||
local output = f:read('*all')
|
|
||||||
f:close()
|
|
||||||
log = log .. output .. const_log_end
|
|
||||||
else
|
|
||||||
log = log .. "Failed" .. const_log_end
|
|
||||||
end
|
|
||||||
local result = {
|
local result = {
|
||||||
async = false,
|
async = false,
|
||||||
log = log
|
log = log
|
||||||
@ -236,15 +228,7 @@ function delete_wxedge()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function restart_wxedge()
|
function restart_wxedge()
|
||||||
local f = io.popen("docker restart wxedge", "r")
|
local log = iform.exec_to_log("docker restart wxedge")
|
||||||
local log = "docker restart wxedge\n"
|
|
||||||
if f then
|
|
||||||
local output = f:read('*all')
|
|
||||||
f:close()
|
|
||||||
log = log .. output .. const_log_end
|
|
||||||
else
|
|
||||||
log = log .. "Failed" .. const_log_end
|
|
||||||
end
|
|
||||||
local result = {
|
local result = {
|
||||||
async = false,
|
async = false,
|
||||||
log = log
|
log = log
|
||||||
@ -252,26 +236,28 @@ function restart_wxedge()
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function fork_exec(command)
|
function blocks()
|
||||||
local pid = nixio.fork()
|
local f = io.popen("lsblk -s -f -b -o NAME,FSSIZE,MOUNTPOINT --json", "r")
|
||||||
if pid > 0 then
|
local vals = {}
|
||||||
return
|
if f then
|
||||||
elseif pid == 0 then
|
local ret = f:read("*all")
|
||||||
-- change to root dir
|
f:close()
|
||||||
nixio.chdir("/")
|
local obj = jsonc.parse(ret)
|
||||||
|
for _, val in pairs(obj["blockdevices"]) do
|
||||||
-- patch stdin, out, err to /dev/null
|
local fsize = val["fssize"]
|
||||||
local null = nixio.open("/dev/null", "w+")
|
if string.len(fsize) > 10 and val["mountpoint"] then
|
||||||
if null then
|
-- fsize > 1G
|
||||||
nixio.dup(null, nixio.stderr)
|
vals[#vals+1] = val["mountpoint"]
|
||||||
nixio.dup(null, nixio.stdout)
|
end
|
||||||
nixio.dup(null, nixio.stdin)
|
end
|
||||||
if null:fileno() > 2 then
|
end
|
||||||
null:close()
|
return vals
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
function dup_array(a)
|
||||||
-- replace with target command
|
local a2 = {}
|
||||||
nixio.exec("/bin/sh", "-c", command)
|
for _, val in pairs(a) do
|
||||||
end
|
table.insert(a2, val)
|
||||||
|
end
|
||||||
|
return a2
|
||||||
end
|
end
|
||||||
|
@ -8,13 +8,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.IstoreosFormEnv = {
|
window.IstoreosFormConfig = {
|
||||||
getApi:"/cgi-bin/luci/admin/services/wxedge/form/",
|
getApi:"/cgi-bin/luci/admin/services/wxedge/form/",
|
||||||
logApi:"/cgi-bin/luci/admin/services/wxedge/log",
|
logApi:"/cgi-bin/luci/admin/services/wxedge/log",
|
||||||
submitApi:"/cgi-bin/luci/admin/services/wxedge/submit"
|
submitApi:"/cgi-bin/luci/admin/services/wxedge/submit"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/luci-static/wxedge/index.js?v=<%=math.random(1,100000)%>"></script>
|
<script type="module" crossorigin src="/luci-static/iform/1.0/index.js?v=<%=math.random(1,100000)%>"></script>
|
||||||
<link rel="stylesheet" href="/luci-static/wxedge/style.css?v=<%=math.random(1,100000)%>">
|
<link rel="stylesheet" href="/luci-static/iform/1.0/style.css?v=<%=math.random(1,100000)%>">
|
||||||
|
|
||||||
<%+footer%>
|
<%+footer%>
|
||||||
|
@ -40,8 +40,8 @@ run_action() {
|
|||||||
|
|
||||||
do_install() {
|
do_install() {
|
||||||
local CACHE_PATH=`uci get wxedge.@wxedge[0].cache_path 2>/dev/null`
|
local CACHE_PATH=`uci get wxedge.@wxedge[0].cache_path 2>/dev/null`
|
||||||
if [ -z "$cache"]; then
|
if [ -z "${CACHE_PATH}"]; then
|
||||||
echo "cache path is empty!" >&2
|
echo "cache path is empty!" >>${LOGFILE}
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
[lock-scroll=true]{overflow:hidden!important}.software-log_shade[data-v-41d6b36f],.software-log_shade *[data-v-41d6b36f]{-webkit-box-sizing:border-box;-webkit-tap-highlight-color:transparent;box-sizing:border-box;word-wrap:break-word;outline:none}.software-log_shade[data-v-41d6b36f]{width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;position:fixed;inset:0;z-index:99999}.software-log_shade .software-log_shade__bg[data-v-41d6b36f]{position:fixed;inset:0;background:rgba(68,79,83,.94) none repeat scroll 0 0!important;background-position:0 0;background-size:cover;opacity:.94}.software-log_shade .software-log_shade__pannel[data-v-41d6b36f]{width:800px;min-width:800px;border-radius:10px;z-index:100;box-shadow:3px 3px 10px #000;background:rgba(0,0,0,.9);padding:10px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-title[data-v-41d6b36f]{text-align:center;font-size:18px;color:#9f0;padding:10px;font-weight:700}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-now i[data-v-41d6b36f]{color:#fc0;font-style:normal}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content[data-v-41d6b36f]{padding:10px;width:100%;text-align:center;overflow:hidden}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]{width:100%;border:0px solid #222;font-family:Lucida Console;font-size:11px;background:transparent;color:#fff;outline:none;overflow-x:hidden;resize:none;transition:.5s}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]:focus,.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]:hover{box-shadow:none;border-color:#fff0!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]::-webkit-scrollbar{width:5px;height:5px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]::-webkit-scrollbar-thumb{height:30px;outline:none;border:none;border-radius:1rem;background-color:#4c595c;-webkit-border-radius:1rem}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-41d6b36f]::-webkit-scrollbar-track-piece{background:none;-webkit-border-radius:0;border-radius:0}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn[data-v-41d6b36f]{width:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-41d6b36f]{visibility:visible;min-width:88px;font-weight:bolder;text-shadow:1px 1px 0px black;border-radius:8px;height:33px;font-family:Verdana,Microsoft Yahei UI,sans-serif;font-size:12px;padding:0 .7em;width:auto;min-width:122px;margin:0 10px;cursor:pointer;background:#090a0a!important;border:1px solid #fff!important;color:#fff!important;opacity:1!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-41d6b36f]:hover{opacity:.9!important}.cbi-section .title{font-size:1.1rem;line-height:1;display:block;width:100%;margin:0;color:#32325d;padding:1rem 1.25rem}.cbi-page-actions{display:inline-block;width:100%}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
|
Loading…
x
Reference in New Issue
Block a user