mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-03 18:53:56 +08:00
This commit is contained in:
1 parent
c7bafc635d
commit
c71da84035
264 files changed
+8169
-3944
No files matched your search
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
let ubus = require('ubus');
|
||||
let state = { calls: [], timeout: false };
|
||||
|
||||
function popen(command, mode) {
|
||||
push(state.calls, command);
|
||||
if (state.timeout) return null;
|
||||
let name = match(command, /\"name\":\"([^\"]+)\"/);
|
||||
let service_name = name ? name[1] : null;
|
||||
let instance = service_name ? ubus.state.services[service_name] : null;
|
||||
let response = {};
|
||||
if (instance != null) response[service_name] = instance;
|
||||
return {
|
||||
read: function() { return sprintf('%J', response); },
|
||||
close: function() { return true; }
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
state: state,
|
||||
popen: popen,
|
||||
unlink: function() { return true; }
|
||||
};
|
||||
Reference in new issue
Block a user