add create user and gateway lua scripts
This commit is contained in:
parent
af4a225b39
commit
69a65aa413
|
@ -0,0 +1,23 @@
|
||||||
|
name = argv[1];
|
||||||
|
realm = argv[2];
|
||||||
|
username = argv[3];
|
||||||
|
password = argv[4];
|
||||||
|
register = argv[5];
|
||||||
|
|
||||||
|
conf = "/usr/local/freeswitch/conf"
|
||||||
|
dir = conf .. "/sip_profiles/external/"
|
||||||
|
file_name = dir .. "/" .. name .. ".xml"
|
||||||
|
|
||||||
|
conf_file = io.open(file_name, "w+")
|
||||||
|
|
||||||
|
conf_file:write('<include>\n')
|
||||||
|
conf_file:write(' <gateway name="' .. name .. '">\n')
|
||||||
|
conf_file:write(' <param name="realm" value="' .. realm .. '"/>\n')
|
||||||
|
conf_file:write(' <param name="username" value="' .. username .. '"/>\n')
|
||||||
|
conf_file:write(' <param name="password" value="' .. password .. '"/>\n')
|
||||||
|
conf_file:write(' <param name="register" value="' .. register .. '"/>\n')
|
||||||
|
conf_file:write(' </gateway>\n')
|
||||||
|
conf_file:write('<include>\n')
|
||||||
|
|
||||||
|
api = freeswitch.API()
|
||||||
|
api:execute("sofia profile external rescan")
|
|
@ -0,0 +1,21 @@
|
||||||
|
user_id = argv[1];
|
||||||
|
if (user_id == nil or user_id == "") then os.exit() end
|
||||||
|
|
||||||
|
conf = "/usr/local/freeswitch/conf"
|
||||||
|
dir = conf .. "/directory/default"
|
||||||
|
template = dir .. "/1001.xml"
|
||||||
|
dest = dir .. "/" .. user_id .. ".xml"
|
||||||
|
|
||||||
|
template_file = io.open(template, "r")
|
||||||
|
dest_file = io.open(dest, "a+")
|
||||||
|
print(dest_file)
|
||||||
|
while true do
|
||||||
|
line = template_file:read("*line")
|
||||||
|
if line == nil then break end
|
||||||
|
line = line:gsub("1001", user_id)
|
||||||
|
print(line)
|
||||||
|
dest_file:write(line .. "\n")
|
||||||
|
end
|
||||||
|
|
||||||
|
api = freeswitch.API()
|
||||||
|
api:execute("reloadxml")
|
Loading…
Reference in New Issue