paulbsd-salt/states/haproxy/scripts/compile.lua
Paul e9b2c207f9
All checks were successful
continuous-integration/drone/push Build is passing
updated haproxy state
2024-05-25 13:54:44 +02:00

26 lines
834 B
Lua

local lfs = require("lfs")
local modpath = "/etc/haproxy/mods"
local compile = {}
local lua_version = "5.3"
local user = "haproxy"
local group = "haproxy"
local libs = {"-ljansson", "-lmaxminddb", "-lcurl"}
function compile.check(module)
local sourcepath = string.format("%s/%s.c", modpath, module)
local binpath = string.format("%s/%s.so", modpath, module)
local binexists = io.open(binpath)
if not binexists or (binexists and lfs.attributes(sourcepath).change > lfs.attributes(binpath).change ) then
local cmd = string.format("cc -I/usr/include/ -I/usr/include/lua%s/ -fPIC -shared -o %s %s %s", lua_version, binpath, sourcepath, table.concat(libs," "))
local res = io.popen(cmd)
io.popen("chown %s:%s %s", user, group, binpath)
io.popen(string.format("chmod 600 %s",binpath))
end
end
return compile