2 -- all lua code provided by https://github.com/jow-/
3 -- thank you very much!
5 function apply_acls(filename, session)
6 local json = require
"luci.jsonc"
7 local util = require
"luci.util"
8 local fs = require
"nixio.fs"
12 local acl = json.parse(fs.readfile(filename))
13 if type(acl) ~=
"table" then
18 for group, perms in pairs(acl) do
20 for perm, scopes in pairs(perms) do
21 if type(scopes) ==
"table" then
23 for scope, objects in pairs(scopes) do
24 if type(objects) ==
"table" then
25 if not grants[scope] then
29 if next(objects) ==
1 then
31 for _, object in ipairs(objects) do
32 if not grants[scope][object] then
33 grants[scope][object] = { }
35 table.insert(grants[scope][object], perm)
39 for object, funcs in pairs(objects) do
40 if type(funcs) ==
"table" then
42 for _, func in ipairs(funcs) do
43 if not grants[scope][object] then
44 grants[scope][object] = { }
46 table.insert(grants[scope][object], func)
57 local _, scope, object, func
58 for scope, _ in pairs(grants) do
60 for object, _ in pairs(_) do
61 for _, func in ipairs(_) do
62 table.insert(objects, { object, func })
66 util.ubus(
"session",
"grant", {
67 ubus_rpc_session = session,
68 scope = scope, objects = objects
73 apply_acls(
"/usr/share/rpcd/acl.d/attendedsysupgrade.json", luci.dispatcher.context.authsession)
76 <h2 name=
"content"><%:Attended Sysupgrade%
></h2>
77 <div class=
"cbi-map-descr">
78 Easily search and install new releases and package upgrades. Sysupgrade firmware are created on demand based on locally installed packages.
80 <div style=
"display: none" id=
"info_box" class=
"alert-message info"></div>
81 <div style=
"display: none" id=
"error_box" class=
"alert-message danger"></div>
82 <div style=
"display: none" id=
"packages" class=
"alert-message success"></div>
84 <textarea style=
"display: none; width: 100%;" id=
"edit_packages" rows=
"15"></textarea>
86 <fieldset class=
"cbi-section">
87 <form method=
"post" action=
"">
88 <div class=
"cbi-selection-node">
89 <div class=
"cbi-value" id=
"keep_container" style=
"display: none">
90 <div class=
"cbi-section-descr">
91 Check
"Keep settings" to retain the current configuration (requires a compatible firmware).
93 <label class=
"cbi-value-title" for=
"keep">Keep settings:
</label>
94 <div class=
"cbi-value-field">
95 <input name=
"keep" id=
"keep" checked=
"checked" type=
"checkbox">
98 <div class=
"cbi-value" id=
"edit_button" style=
"display: none">
99 <div class=
"cbi-value-field">
100 <input class=
"cbi-button" value=
"Edit installed packages" onclick=
"edit_packages()" type=
"button">
103 <div class=
"cbi-value cbi-value" id=
"server_div" style=
"display:none">
104 <label class=
"cbi-value-title" for=
"server">Server:
</label>
105 <div class=
"cbi-value-field">
106 <input onclick=
"edit_server()" class=
"cbi-button cbi-button-edit" value=
"" type=
"button" id=
"server" name=
"server">
109 <div class=
"cbi-value cbi-value-last">
110 <div class=
"cbi-value-field">
111 <input class=
"cbi-button cbi-button-apply" value=
"Search for upgrades" style=
"display: none" onclick=
"upgrade_check()" type=
"button" id=
"upgrade_button">
117 <script type=
"text/javascript">
119 data[
"ubus_rpc_session"] =
"<%=luci.dispatcher.context.authsession%>"
120 origin = document.location.href.replace(location.pathname,
"")
121 ubus_url = origin +
"/ubus/"
123 <script type=
"text/javascript" src=
"<%=resource%>/attendedsysupgrade.js"></script>