summaryrefslogtreecommitdiffstats
path: root/config/templates/cyberdata-template.lua
blob: e05bdd920d5d5ec1dfc52eac6e7cb93f176c4df6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%
-- CyberData Intercom Configuration File Template
local values = ...

require 'LuaXml'
local init_cfg = xml.load("/var/www/provisioning/htdocs/CyberData/init.cfg")

-- <IPSettings>

-- <SIPSettings>

for pg, pg_t in pairs(values) do
	-- Is it of the form regX ?
	local num = string.match(pg, 'reg(%d+)')
	if num then
		if pg_t.extension ~= "" then
			init_cfg[2]:append("SIPServer")[1] = values.device.registrar
			init_cfg[2]:append("SIPUserID")[1] = pg_t.extension
			init_cfg[2]:append("SIPAuthID")[1] = pg_t.extension
			init_cfg[2]:append("SIPAuthPassword")[1] = pg_t.password
			init_cfg[2]:append("DialoutExtension0")[1] = pg_t.hotlinedestination
			init_cfg[2]:append("DialoutID0")[1] = pg_t.callerid
		end
	end
end


-- <ClockSettings>

init_cfg[3]:append("NTPServer")[1] = values.device.sntpserver
init_cfg[3]:append("NTPTimezone")[1] = values.device.timezone

-- init_cfg:save("TEST-cyberdata.xml")

print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
print(init_cfg)
%>