Commit 2285a3c1 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

util: run function

parent 5c80fcb7
...@@ -340,11 +340,7 @@ if not call( ...@@ -340,11 +340,7 @@ if not call(
end end
) )
end end
pid = util.run(arg[0], 'fallback')
local stdio, stdout
pid, stdio, stdout = lpc.run(arg[0], 'fallback')
stdio:close()
stdout:close()
end end
local function kill() local function kill()
......
--[[ --[[
Ipset file dumper for Alpine Wall Ipset file dumper for Alpine Wall
Copyright (C) 2012-2016 Kaarle Ritvanen Copyright (C) 2012-2019 Kaarle Ritvanen
See LICENSE file for license details See LICENSE file for license details
]]-- ]]--
...@@ -20,10 +20,11 @@ end ...@@ -20,10 +20,11 @@ end
function IPSet:create() function IPSet:create()
for name, ipset in pairs(self.config) do for name, ipset in pairs(self.config) do
local pid = lpc.run( if not lpc.wait(
util.run(
'ipset', '-!', 'create', name, table.unpack(ipset.options) 'ipset', '-!', 'create', name, table.unpack(ipset.options)
) )
if lpc.wait(pid) ~= 0 then ) ~= 0 then
util.printmsg('ipset creation failed: '..name) util.printmsg('ipset creation failed: '..name)
end end
end end
......
--[[ --[[
Utility module for Alpine Wall Utility module for Alpine Wall
Copyright (C) 2012-2017 Kaarle Ritvanen Copyright (C) 2012-2019 Kaarle Ritvanen
See LICENSE file for license details See LICENSE file for license details
]]-- ]]--
local M = {} local M = {}
local lpc = require('lpc')
function M.split(s, sep) function M.split(s, sep)
if s == '' then return {} end if s == '' then return {} end
local res = {} local res = {}
...@@ -150,4 +153,12 @@ function M.printtabular(tbl) M.printtabulars({tbl}) end ...@@ -150,4 +153,12 @@ function M.printtabular(tbl) M.printtabulars({tbl}) end
function M.printmsg(msg) io.stderr:write(msg..'\n') end function M.printmsg(msg) io.stderr:write(msg..'\n') end
function M.run(...)
local pid, stdin, stdout = lpc.run(...)
stdin:close()
stdout:close()
return pid
end
return M return M
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment