🍓 Sync 2025-11-12 00:12:28
This commit is contained in:
@@ -23,6 +23,10 @@ function index()
|
||||
entry({"admin", "store", "log"}, call("store_log"))
|
||||
entry({"admin", "store", "uid"}, call("action_user_id"))
|
||||
entry({"admin", "store", "upload"}, post("store_upload"))
|
||||
entry({"admin", "store", "del_record"}, post("store_del_record"))
|
||||
entry({"admin", "store", "unrun"}, post("store_unrun"))
|
||||
entry({"admin", "store", "run_records"}, call("store_run_records"))
|
||||
|
||||
entry({"admin", "store", "check_self_upgrade"}, call("check_self_upgrade"))
|
||||
entry({"admin", "store", "do_self_upgrade"}, post("do_self_upgrade"))
|
||||
entry({"admin", "store", "toggle_docker"}, post("toggle_docker"))
|
||||
@@ -435,11 +439,7 @@ function store_upload()
|
||||
local code, out, err
|
||||
out = ""
|
||||
if finished then
|
||||
if string.lower(string.sub(path, -4, -1)) == ".run" then
|
||||
code, out, err = _action("sh", "-c", "ls -l \"%s\"; md5sum \"%s\" 2>/dev/null; chmod 755 \"%s\" && \"%s\"; RET=$?; rm -f \"%s\"; exit $RET" %{ path, path, path, path, path })
|
||||
else
|
||||
code, out, err = _action("sh", "-c", "opkg install \"%s\"; RET=$?; rm -f \"%s\"; exit $RET" %{ path, path })
|
||||
end
|
||||
code, out, err = _action(myopkg, "dotrun", path)
|
||||
else
|
||||
code = 500
|
||||
err = "upload failed!"
|
||||
@@ -454,6 +454,46 @@ function store_upload()
|
||||
luci.http.write_json(ret)
|
||||
end
|
||||
|
||||
function store_unrun()
|
||||
local record_id = luci.http.formvalue("id")
|
||||
if record_id == nil or record_id == "" then
|
||||
luci.http.status(400, "Bad Request")
|
||||
return
|
||||
end
|
||||
local code, out, err = _action(myopkg, "unrun", record_id)
|
||||
local ret = {
|
||||
code = code,
|
||||
stdout = out,
|
||||
stderr = err
|
||||
}
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(ret)
|
||||
end
|
||||
|
||||
function store_run_records()
|
||||
local util = require "luci.util"
|
||||
local run_records = util.exec(myopkg .. " run_records")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write("{\n\"code\":200,\n\"records\":")
|
||||
luci.http.write(run_records)
|
||||
luci.http.write("\n}\n")
|
||||
end
|
||||
|
||||
function store_del_record()
|
||||
local nixio = require "nixio"
|
||||
local os = require "os"
|
||||
local rshift = nixio.bit.rshift
|
||||
|
||||
local record_id = luci.http.formvalue("id")
|
||||
if record_id == nil or record_id == "" then
|
||||
luci.http.status(400, "Bad Request")
|
||||
return
|
||||
end
|
||||
local r = os.execute(myopkg.." del_record "..luci.util.shellquote(record_id).." >/dev/null 2>&1")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({code=rshift(r,8)})
|
||||
end
|
||||
|
||||
function configured()
|
||||
local uci = luci.http.formvalue("uci")
|
||||
if not validate_pkgname(uci) then
|
||||
|
||||
Reference in New Issue
Block a user