<% -- Linksys ATA Configuration File Template local values = ... --[[ -- Parameters values["device"]["adminpassword"] = "" values["device"]["digitmap"] = "" values["device"]["mac"] = "" values["device"]["musiconhold"] = "" values["device"]["registrar"] = "" values["device"]["sntpserver"] = "" values["device"]["template"] = "/etc/provisioning/templates/linksysata-template.lua" -- Unimplemented -- values["device"]["timezone"] = "" values["regX"]["callerid"] = "" values["regX"]["extension"] = "" values["regX"]["forwardall"] = "" values["regX"]["forwardallenable"] = false values["regX"]["forwardbusy"] = "" values["regX"]["forwardbusyenable"] = false values["regX"]["forwardnoanswer"] = "" values["regX"]["forwardnoanswerenable"] = false values["regX"]["password"] = "" -- Unimplemented -- values["services"]["callhistoryenable"] = true values["services"]["callwaitingenable"] = true values["services"]["forwarding"] = true -- Unimplemented -- values["services"]["hotlineenable"] = false -- Unimplemented -- values["services"]["mailbox"] = "" -- Unimplemented -- values["services"]["speeddialenable"] = true --]] local function yesno ( bool ) if bool then return "Yes" else return "No" end end local function xml_elem(elem,value,permissions,i) local e = elem if i then e = elem.."_"..tostring(i).."_" end local output = {"<", e, ' ua="'} output[#output+1] = (permissions or "na")..'">' if type(value) == "boolean" then output[#output+1] = yesno(value) elseif value then output[#output+1] = value end output[#output+1] = "" io.write(table.concat(output)) end %> <%= values.device.adminpassword %> <%= values.device.adminpassword %> <%= values.reg1.extension %> <%= values.device.sntpserver %> <% 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 xml_elem("Line_Enable", "Yes", "na", num) xml_elem("MOH_Server", values.device.musiconhold, "na", num) xml_elem("Proxy", values.device.registrar, "na", num) xml_elem("Call_Waiting_Serv", (values.services and values.services.callwaitingenable), "na", num) xml_elem("Dial_Plan", "( "..values.device.digitmap.." )", "na", num) if pg_t.callerid == "" then pg_t.callerid = pg_t.extension end xml_elem("Display_Name", pg_t.callerid, "na", num) xml_elem("User_ID", pg_t.extension, "na", num) xml_elem("Password", pg_t.password, "na", num) local forwarding = { {param="forwardall", xml="Cfwd_All_Dest"}, {param="forwardbusy", xml="Cfwd_Busy_Dest"}, {param="forwardnoanswer", xml="Cfwd_No_Ans_Dest"} } for i,f in ipairs(forwarding) do if value.services.forwarding and pg_t[f.param.."enable"] then xml_elem(f.xml, pg_t[f.param], "na", num) else xml_elem(f.xml, "", "na", num) end end else xml_elem("Line_Enable", "No", "na", num) -- xml_elem("Cfwd_No_Ans_Delay", "0", "na", num) end end end %>