luci: Fix getting CPU arch info

This commit is contained in:
remittor
2025-12-17 10:10:18 +03:00
parent 1364bcbf1a
commit 565ef66299
2 changed files with 11 additions and 4 deletions

View File

@@ -47,7 +47,7 @@ return view.extend({
fs.exec('/bin/busybox', [ 'ps' ]), // process list
fs.exec(tools.packager.path, tools.packager.args), // installed packages
tools.getStratList(), // nfqws strategy list
fs.exec('sh', [ '-c', '. /etc/openwrt_release && printf "%s" "$DISTRIB_ARCH"' ]), // CPU arch
fs.exec('/bin/cat', [ '/etc/openwrt_release' ]), // CPU arch
uci.load(tools.appName), // config
]).catch(e => {
ui.addNotification(null, E('p', _('Unable to execute or read contents')
@@ -71,10 +71,11 @@ return view.extend({
let svc_info = status_array[2]; // stdout: JSON as text
let proc_list = status_array[3]; // stdout: multiline text
let pkg_list = status_array[4]; // stdout: installed packages
this.nfqws_strat_list = status_array[5]; // array of strat names
let pkg_arch = status_array[6]; // stdout: CPU arch
let stratlist = status_array[5]; // array of strat names
let sys_info = status_array[6]; // stdout: openwrt distrib info
this.pkg_arch = (pkg_arch.code == 0) ? pkg_arch.stdout.trim() : 'unknown';
this.nfqws_strat_list = stratlist;
this.pkg_arch = tools.getConfigPar(sys_info.stdout, 'DISTRIB_ARCH', 'unknown');
//console.log('svc_en: ' + svc_en.code);
svc_en = (svc_en.code == 0) ? true : false;

View File

@@ -174,6 +174,12 @@ return baseclass.extend({
const processed = trim ? rawLines.map(line => line.trim()) : rawLines.slice();
return removeEmpty ? processed.filter(line => line.length > 0) : processed;
},
getConfigPar: function(txt, key, defval = null) {
const re = new RegExp(`^${key}\\s*=\\s*(['"])(.*?)\\1`, 'm');
const m = txt.match(re);
return m ? m[2] : defval;
},
decode_pkg_list: function(pkg_list) {
let pkg_dict = { };