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

util: run function

parent 5c80fcb7
......@@ -340,11 +340,7 @@ if not call(
end
)
end
local stdio, stdout
pid, stdio, stdout = lpc.run(arg[0], 'fallback')
stdio:close()
stdout:close()
pid = util.run(arg[0], 'fallback')
end
local function kill()
......
--[[
Ipset file dumper for Alpine Wall
Copyright (C) 2012-2016 Kaarle Ritvanen
Copyright (C) 2012-2019 Kaarle Ritvanen
See LICENSE file for license details
]]--
......@@ -20,10 +20,11 @@ end
function IPSet:create()
for name, ipset in pairs(self.config) do
local pid = lpc.run(
'ipset', '-!', 'create', name, table.unpack(ipset.options)
)
if lpc.wait(pid) ~= 0 then
if not lpc.wait(
util.run(
'ipset', '-!', 'create', name, table.unpack(ipset.options)
)
) ~= 0 then
util.printmsg('ipset creation failed: '..name)
end
end
......
--[[
Utility module for Alpine Wall
Copyright (C) 2012-2017 Kaarle Ritvanen
Copyright (C) 2012-2019 Kaarle Ritvanen
See LICENSE file for license details
]]--
local M = {}
local lpc = require('lpc')
function M.split(s, sep)
if s == '' then return {} end
local res = {}
......@@ -150,4 +153,12 @@ function M.printtabular(tbl) M.printtabulars({tbl}) 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
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