create_gateway.lua 763 B

1234567891011121314151617181920212223
  1. name = argv[1];
  2. realm = argv[2];
  3. username = argv[3];
  4. password = argv[4];
  5. register = argv[5];
  6. conf = "/usr/local/freeswitch/conf"
  7. dir = conf .. "/sip_profiles/external/"
  8. file_name = dir .. "/" .. name .. ".xml"
  9. conf_file = io.open(file_name, "w+")
  10. conf_file:write('<include>\n')
  11. conf_file:write(' <gateway name="' .. name .. '">\n')
  12. conf_file:write(' <param name="realm" value="' .. realm .. '"/>\n')
  13. conf_file:write(' <param name="username" value="' .. username .. '"/>\n')
  14. conf_file:write(' <param name="password" value="' .. password .. '"/>\n')
  15. conf_file:write(' <param name="register" value="' .. register .. '"/>\n')
  16. conf_file:write(' </gateway>\n')
  17. conf_file:write('<include>\n')
  18. api = freeswitch.API()
  19. api:execute("sofia profile external rescan")