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="status_box" class="alert-message info"></div>
81 <div style="display: none" id="packages" class="alert-message success"></div>
83 <textarea style="display: none; width: 100%;" id="edit_packages" rows="15"></textarea>
85 <fieldset class="cbi-section">
86 <form method="post" action="">
87 <div class="cbi-selection-node">
88 <div class="cbi-value" id="keep_container" style="display: none">
89 <div class="cbi-section-descr">
90 Check "Keep settings" to retain the current configuration (requires a compatible firmware).
92 <label class="cbi-value-title" for="keep">Keep settings:</label>
93 <div class="cbi-value-field">
94 <input name="keep" id="keep" checked="checked" type="checkbox">
97 <div class="cbi-value" id="edit_button" style="display: none">
98 <div class="cbi-value-field">
99 <input class="cbi-button" value="Edit installed packages" onclick="edit_packages()" type="button">
102 <div class="cbi-value cbi-value" id="server_div" style="display:none">
103 <label class="cbi-value-title" for="server">Server:</label>
104 <div class="cbi-value-field">
105 <input onclick="edit_server()" class="cbi-button cbi-button-edit" value="" type="button" id="server" name="server">
108 <div class="cbi-value cbi-value-last">
109 <div class="cbi-value-field">
110 <input class="cbi-button cbi-button-apply" value="Search for upgrades" style="display: none" onclick="upgrade_check()" type="button" id="upgrade_button">
116 <script type="text/javascript">
118 data["ubus_rpc_session"] = "<%=luci.dispatcher.context.authsession%>"
119 origin = document.location.href.replace(location.pathname, "")
120 ubus_url = origin + "/ubus/"
122 <script type="text/javascript" src="<%=resource%>/attendedsysupgrade.js"></script>