libs/core: rework luci.model.uci.apply() to return the commandline as table, suitable for passing to nixio.exec()
This commit is contained in:
parent
79231d68be
commit
574eff4e8e
1 changed files with 7 additions and 4 deletions
|
@ -32,7 +32,7 @@ local table = require "table"
|
||||||
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
||||||
local require, getmetatable = require, getmetatable
|
local require, getmetatable = require, getmetatable
|
||||||
local error, pairs, ipairs = error, pairs, ipairs
|
local error, pairs, ipairs = error, pairs, ipairs
|
||||||
local type, tostring, tonumber = type, tostring, tonumber
|
local type, tostring, tonumber, unpack = type, tostring, tonumber, unpack
|
||||||
|
|
||||||
--- LuCI UCI model library.
|
--- LuCI UCI model library.
|
||||||
-- The typical workflow for UCI is: Get a cursor instance from the
|
-- The typical workflow for UCI is: Get a cursor instance from the
|
||||||
|
@ -69,9 +69,12 @@ local Cursor = getmetatable(inst)
|
||||||
-- @param command Don't apply only return the command
|
-- @param command Don't apply only return the command
|
||||||
function Cursor.apply(self, configlist, command)
|
function Cursor.apply(self, configlist, command)
|
||||||
configlist = self:_affected(configlist)
|
configlist = self:_affected(configlist)
|
||||||
local reloadcmd = "/sbin/luci-reload " .. table.concat(configlist, " ")
|
if command then
|
||||||
|
return { "/sbin/luci-reload", unpack(configlist) }
|
||||||
return command and reloadcmd or os.execute(reloadcmd .. " >/dev/null 2>&1")
|
else
|
||||||
|
return os.execute("/sbin/luci-reload %s >/dev/null 2>&1"
|
||||||
|
% table.concat(configlist, " "))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue