You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lua-ngcp-kamailio/scripts/ngcp-dlgcnt-clean

59 lines
1.3 KiB

#!/usr/bin/env lua5.1
--local ut = require 'ngcp.utils'.table
local NGCPDlg = require 'ngcp.dlgcnt'
local config = "/etc/kamailio/proxy/dlgcnt.lua.cfg"
-- luacheck: globals dlg_config
sr = {}
sr.log = function (level, str)
print(string.format("[%s] %s", level, str))
end
local function get_config()
if os.getenv('DLG_CONFIG') then
config = os.getenv('DLG_CONFIG')
end
local ok,e = pcall(dofile,config)
if not ok then
io.stderr:write(e..'\n')
io.stderr:write("using defaults\n")
end
end
local function usage()
print("ngcp-dlgcnt-clean callid")
end
if #arg ~= 1 then
io.stderr:write("wrong number of arguments\n");
usage()
os.exit(2)
end
if arg[1] == "-h" then usage(); os.exit(0); end
get_config()
local dlg = NGCPDlg:new()
if arg[1] == '-c' then
print(tostring(dlg.config.pair.db))
os.exit(0)
elseif arg[1] == '-C' then
print(tostring(dlg_config.pair.host))
os.exit(0)
end
if dlg_config then
dlg.config.central.host = dlg_config.central.host
dlg.config.central.port = dlg_config.central.port
dlg.config.central.db = dlg_config.central.db
dlg.config.pair.host = dlg_config.pair.host
dlg.config.pair.port = dlg_config.pair.port
dlg.config.pair.db = dlg_config.pair.db
--print(string.format("dlg.config:%s", ut.tostring(dlg.config)))
end
dlg:del(arg[1])