[Freeswitch-users] Serving sofia.conf via lua (updated)

Antony Stone Antony.Stone at freeswitch.open.source.it
Tue Nov 30 10:20:02 UTC 2021


Hi.

Sending again with a bit of clarification - my original message hasn't hit the 
list yet, so I'm hoping people can reply to just this one...


I am trying to get Freeswitch to get its sofia configuation from lua instead of 
static XML files.

https://freeswitch.org/confluence/display/FREESWITCH/mod_xml_curl tells me for 
example that "Section: configuration - This is used to send back configuration 
files such as sofia.conf."  Yes, I know that that page refers to mod_xml_curl 
and not mod_xml_lua but I'm pretty certain that the principle is the same, and 
https://freeswitch.org/confluence/display/FREESWITCH/Serving+Configuration+with+Lua 
seems to confirm this, although is it much thinner on examples.  I do not that 
this page also says "there is no Lua page yet, and Lua-related docs are 
scattered all over the place..." :(

So, anyway, I'm pretty sure what I want to do should be possible, but nowhere 
have I so far been able to find a fully working example telling me how to do 
it.

My understanding so far is that:

1. I need to create a lua script which generates the *complete* XML as would 
be served from /etc/freeswitch/autoload_configs/sofia.conf.xml and all its 
included sub-directories/files

2. This XML as output from the script should be enclosed within tags:

  <document type="freeswitch/xml">
    <section name="configuration">
      ... XML goes here ...
    </section>
  </document>

3. I should place this lua script in freeswitch's scripting directory, which 
on my (Debian) machine is /usr/share/freeswitch/scripts

4. I need to enable this script to be run by including in 
/etc/freeswitch/autoload_configs/lua.conf.xml:

    <param name="xml-handler-script" value="sofia.conf.lua"/>
    <param name="xml-handler-bindings" value="configuration"/>


The first thing which is not clear to me is what I should do about 
/etc/freeswitch/autoload_configs/sofia.conf.xml

 - if I leave it as it is, it appears to be used in the normal way, and my lua 
script is ignored
 - if I delete it (or rename it to sofia.conf.xml.noload for example) then sofia 
doesn't get loaded *at all* and when I go into fs_cli I do not even have a 
"sofia" command
 - if I "touch" the filename so that 
/etc/reeswitch/autoload_configs/sofia.conf.xml exists but is empty, I get the 
same result egain - the "sofia" command does not even exist in the cli


So, can anyone point me at how to join these things up correctly so that I can 
serve sofia configuration settings from a lua script?


I've been told here that:

On Friday 05 November 2021 at 12:28:55, David Villasmil wrote:

> In FS there’s the embedded lua. You can do almost anything with it.

I'm struggling to find the documentation telling me how, though :(


Thanks in advance,


Antony.

-- 
"It would appear we have reached the limits of what it is possible to achieve 
with computer technology, although one should be careful with such statements; 
they tend to sound pretty silly in five years."

 - John von Neumann (1949)

                                                   Please reply to the list;
                                                         please *don't* CC me.



More information about the FreeSWITCH-users mailing list