luci-base, luci-mod-status: expose LuCI version via ubus
Instead of scraping the LuCI version from Lua sources, fetch it via ubus in order to be independent from the Lua runtime. Fixes: #6154 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
05194712bb
commit
a27d2dbc32
3 changed files with 15 additions and 7 deletions
|
@ -7,6 +7,7 @@ import { stdin, access, dirname, basename, open, popen, glob, lsdir, readfile, r
|
||||||
import { cursor } from 'uci';
|
import { cursor } from 'uci';
|
||||||
|
|
||||||
import { init_list, init_index, init_enabled, init_action, conntrack_list, process_list } from 'luci.sys';
|
import { init_list, init_index, init_enabled, init_action, conntrack_list, process_list } from 'luci.sys';
|
||||||
|
import { revision, branch } from 'luci.version';
|
||||||
import { statvfs } from 'luci.core';
|
import { statvfs } from 'luci.core';
|
||||||
|
|
||||||
import timezones from 'luci.zoneinfo';
|
import timezones from 'luci.zoneinfo';
|
||||||
|
@ -17,6 +18,12 @@ function shellquote(s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const methods = {
|
const methods = {
|
||||||
|
getVersion: {
|
||||||
|
call: function(request) {
|
||||||
|
return { revision, branch };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
getInitList: {
|
getInitList: {
|
||||||
args: { name: 'name' },
|
args: { name: 'name' },
|
||||||
call: function(request) {
|
call: function(request) {
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
'require fs';
|
'require fs';
|
||||||
'require rpc';
|
'require rpc';
|
||||||
|
|
||||||
|
var callLuciVersion = rpc.declare({
|
||||||
|
object: 'luci',
|
||||||
|
method: 'getVersion'
|
||||||
|
});
|
||||||
|
|
||||||
var callSystemBoard = rpc.declare({
|
var callSystemBoard = rpc.declare({
|
||||||
object: 'system',
|
object: 'system',
|
||||||
method: 'board'
|
method: 'board'
|
||||||
|
@ -20,7 +25,7 @@ return baseclass.extend({
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
L.resolveDefault(callSystemBoard(), {}),
|
L.resolveDefault(callSystemBoard(), {}),
|
||||||
L.resolveDefault(callSystemInfo(), {}),
|
L.resolveDefault(callSystemInfo(), {}),
|
||||||
fs.lines('/usr/lib/lua/luci/version.lua')
|
L.resolveDefault(callLuciVersion(), { revision: _('unknown version'), branch: 'LuCI' })
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,11 +34,7 @@ return baseclass.extend({
|
||||||
systeminfo = data[1],
|
systeminfo = data[1],
|
||||||
luciversion = data[2];
|
luciversion = data[2];
|
||||||
|
|
||||||
luciversion = luciversion.filter(function(l) {
|
luciversion = luciversion.branch + ' ' + luciversion.revision;
|
||||||
return l.match(/^\s*(luciname|luciversion)\s*=/);
|
|
||||||
}).map(function(l) {
|
|
||||||
return l.replace(/^\s*\w+\s*=\s*['"]([^'"]+)['"].*$/, '$1');
|
|
||||||
}).join(' ');
|
|
||||||
|
|
||||||
var datestr = null;
|
var datestr = null;
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
"file": {
|
"file": {
|
||||||
"/proc/sys/net/netfilter/nf_conntrack_count": [ "read" ],
|
"/proc/sys/net/netfilter/nf_conntrack_count": [ "read" ],
|
||||||
"/proc/sys/net/netfilter/nf_conntrack_max": [ "read" ],
|
"/proc/sys/net/netfilter/nf_conntrack_max": [ "read" ],
|
||||||
"/usr/lib/lua/luci/version.lua": [ "read" ],
|
|
||||||
"/www/luci-static/resources/view/status/include": [ "list" ]
|
"/www/luci-static/resources/view/status/include": [ "list" ]
|
||||||
},
|
},
|
||||||
"ubus": {
|
"ubus": {
|
||||||
|
"luci": [ "getVersion" ],
|
||||||
"file": [ "list", "read" ],
|
"file": [ "list", "read" ],
|
||||||
"system": [ "board", "info" ]
|
"system": [ "board", "info" ]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue