4 This utility can be used to generate an extensions.conf file to match an
5 existing extensions.lua file. As an argument it takes the patch of the
6 extensions.lua file to read from, otherwise it uses
7 /etc/asterisk/extensions.lua.
9 This script can also be used to automatically include extensions.lua in
10 extensions.conf via a #exec as well.
12 #exec /usr/bin/build-extensions-conf.lua -c
19 ]] .. arg
[0] .. [[ [options] [extensions.lua path]
21 This utility can generate an extensions.conf file with all of the contexts in
22 your extensions.lua file defined as including the Lua switch. This is useful
23 if you want to use your extensions.lua file exclusively. By using this utility
24 you dont't have to create each extension in extensions.conf manually.
26 The resulting extensions.conf file is printed to standard output.
28 --contexts-only, -c Don't print the [global] or [general] sections. This
29 is useful for including the generated file into an
30 existing extensions.conf via #include or #exec.
32 --help, -h Print this message.
36 extensions_file
= "/etc/asterisk/extensions.lua"
40 for k
, v
in ipairs(arg
) do
41 if v
:sub(1, 1) == "-" then
42 if v
== "-h" or v
== "--help" then
44 options
["help"] = true
45 elseif v
== "-c" or v
== "--contexts-only" then
46 options
["contexts-only"] = true
49 options
["extensions-file"] = v
53 if options
["help"] then
54 io
.stderr
:write(usage
)
58 if options
["extensions-file"] then
59 extensions_file
= options
["extensions-file"]
62 result
, error_message
= pcall(dofile, extensions_file
)
65 io
.stderr
:write(error_message
.. "\n")
69 if not extensions
then
70 io
.stderr
:write("Error: extensions table not found in '" .. extensions_file
.. "'\n")
74 if not options
["contexts-only"] then
75 io
.stdout
:write("[general]\n\n[globals]\n\n")
78 for context
, extens
in pairs(extensions
) do
79 io
.stdout
:write("[" .. tostring(context
) .. "]\nswitch => Lua\n\n")