2021-01-16 07:15:54 +00:00
< %
-- all lua code provided by https://github.com/jow-/
-- thank you very much!
function apply_acls(filename, session)
local json = require "luci.jsonc"
local util = require "luci.util"
local fs = require "nixio.fs"
local grants = { }
local acl = json.parse(fs.readfile(filename))
if type(acl) ~= "table" then
return
end
local group, perms
for group, perms in pairs(acl) do
local perm, scopes
for perm, scopes in pairs(perms) do
if type(scopes) == "table" then
local scope, objects
for scope, objects in pairs(scopes) do
if type(objects) == "table" then
if not grants[scope] then
grants[scope] = { }
end
if next(objects) == 1 then
local _, object
for _, object in ipairs(objects) do
if not grants[scope][object] then
grants[scope][object] = { }
end
table.insert(grants[scope][object], perm)
end
else
local object, funcs
for object, funcs in pairs(objects) do
if type(funcs) == "table" then
local _, func
for _, func in ipairs(funcs) do
if not grants[scope][object] then
grants[scope][object] = { }
end
table.insert(grants[scope][object], func)
end
end
end
end
end
end
end
end
end
local _, scope, object, func
for scope, _ in pairs(grants) do
local objects = { }
for object, _ in pairs(_) do
for _, func in ipairs(_) do
table.insert(objects, { object, func })
end
end
util.ubus("session", "grant", {
ubus_rpc_session = session,
scope = scope, objects = objects
})
end
end
apply_acls("/usr/share/rpcd/acl.d/sysupgrade.json", luci.dispatcher.context.authsession)
%>
< %+header%>
< h2 name = "content" > < %:Sysupgrade%>< / h2 >
< div class = "cbi-map-descr" >
2021-02-01 15:24:37 +00:00
< %:Easily search and install new releases and package upgrades.%>
2021-01-16 07:15:54 +00:00
< / div >
< div style = "display: none" id = "status_box" class = "alert-message info" > < / div >
< div style = "display: none" id = "packages" class = "alert-message success" > < / div >
< p >
< textarea style = "display: none; width: 100%;" id = "edit_packages" rows = "15" > < / textarea >
< / p >
< fieldset class = "cbi-section" >
< form method = "post" action = "" >
< div class = "cbi-selection-node" >
< div class = "cbi-value" id = "keep_container" style = "display: none" >
< div class = "cbi-section-descr" >
2021-02-01 15:24:37 +00:00
< %:Check "Keep settings" to retain the current configuration.%>
2021-01-16 07:15:54 +00:00
< / div >
2021-02-01 15:24:37 +00:00
< label class = "cbi-value-title" for = "keep" > < %:Keep settings:%>< / label >
2021-01-16 07:15:54 +00:00
< div class = "cbi-value-field" >
< input name = "keep" id = "keep" checked = "checked" type = "checkbox" >
< / div >
< / div >
< div class = "cbi-value" id = "edit_button" style = "display: none" >
< div class = "cbi-value-field" >
2021-02-01 15:24:37 +00:00
< input class = "cbi-button" value = "<%:Edit installed packages%>" onclick = "edit_packages()" type = "button" >
2021-01-16 07:15:54 +00:00
< / div >
< / div >
< div class = "cbi-value cbi-value" id = "server_div" style = "display:none" >
2021-04-12 16:08:35 +00:00
<!--
2021-02-01 15:24:37 +00:00
< label class = "cbi-value-title" for = "server" > < %:Server:%>< / label >
2021-01-16 07:15:54 +00:00
< div class = "cbi-value-field" >
< input onclick = "edit_server()" class = "cbi-button cbi-button-edit" value = "" type = "button" id = "server" name = "server" >
< / div >
2021-02-23 14:10:34 +00:00
-->
2021-04-12 16:08:35 +00:00
< / div >
2021-02-23 14:10:34 +00:00
< input type = "hidden" value = "" id = "server" name = "server" >
2021-01-16 07:15:54 +00:00
< div class = "cbi-value cbi-value-last" >
< div class = "cbi-value-field" >
2021-02-01 15:24:37 +00:00
< input class = "cbi-button cbi-button-apply" value = "<%:Search for upgrades%>" style = "display: none" onclick = "upgrade_check()" type = "button" id = "upgrade_button" >
2021-01-16 07:15:54 +00:00
< / div >
< / div >
< / div >
< / form >
< / fieldset >
< script type = "text/javascript" >
data = {};
data["ubus_rpc_session"] = "< %=luci.dispatcher.context.authsession%>"
origin = document.location.href.replace(location.pathname, "")
ubus_url = origin + "/ubus/"
< / script >
< script type = "text/javascript" src = "<%=resource%>/sysupgrade.js" > < / script >
< %+footer%>