Would it be possible to change PABX settings via CLI or changing files manually?

I asked, because I opened some files to make changes manually as if it were a Pure Asterisk and I came across a message from Freepbx when editing the configuration file, stating that we can not make changes directly in it …

But it turns out we’d like to automate some of the freepbx settings like queuing, creating extensions, creating routing, URA, and so on.
And it would be very formidable if it were possible to do this through a bash script by changing files with regular expressions or even through CLI, or even API.
But in order to see the changes in the freepbx web interface

Could anyone help with this?

Thank you!

FreePBX contains many “custom” configuration files (initially empty), which allow the user to write custom Asterisk dialplan and make other configuration changes, without conflict with the files modified by the GUI. Go to Admin -> Config Edit to see a list of these files.

Also, see Admin -> Bulk Handler, which provides an easy way to add, delete or modify a group of extensions, DIDs, etc. using a script or Excel formula or macro.

If what you’d like to automate is beyond the scope of either of these mechanisms, you could consider:

  1. Look at the PHP code for the module in question and write a script to call the underlying functions.
  2. Learn how the database is modified by the relevant module and perform calls to update the database directly.
  3. Write code to access the web interface, emulating what a browser would do to perform the desired modifications.

Unfortunately, all of the above are at risk of breaking when modules are upgraded.

1 Like

Hello Stewart1, thank you very much for your response.
Really the interest is in modifying the files so that the changes appear in the FreePBX interface.
Apparently the best alternative would be to call PHP functions.
I studied the basics of PHP without getting into object-driven, but I will try to understand the modules and functions.
Thank you!

In FreePBX 15 we have a whole new API system that was designed for this exact reason.

2 Likes

Hello Tony Lewis, Thank you very much for your response and I would like to congratulate you and the whole team for FreePBX!
The API news is simply wonderful!
Is it possible to use FreePBX 15 in production?

It turns out that we are starting a new small business in our region, where we will sell SIP numbers in conjunction with URA + Rows + Extensions for small businesses in my region that need to migrate from old telephony to have VoiP advantages.
And as we will begin with a competitive price to try to reach as many customers as possible, the manual configuration of each customer becomes a little time consuming. So I had the idea of ​​creating a shell script that would automate most of the project and then I was thinking of doing a small system in PHP or JS (so I started PHP and JS) to evolve this script and communicate directly with FreePBX, which would be the chosen orchestrator due to its maturity after all these years of evolution.
We have not yet decided whether the best path would be a great server that would concentrate all clients and would work with your HA module in the future, or if the best way would be to automate the creation of Docker containers for each client.
Your advice would also be greatly appreciated by us.

Thank you one more time!

@viniciusbarreto , Just to let you know before you get too excited, Asterisk makes for a very bad multi-tenant solution. You might want to look elsewhere.

1 Like

Asterisk by itself, sure. Bit donr the right way, it is fine.

1 Like

Hello @dicko I understand you. Thank you very much for your reply.

Hello BlazeStudios, Thank you very much for your reply.
Would you like to share your advice for this case?

@dicko would you hold the same opinion if you used a docker container for each client, if the orchestration (creation and deletion of containers) was automated?

I thought about this possibility, but I came across the following big question:

How to route SIP and RTP traffic to different containers using only a single external IP, securely and steadily?
It would be something like a SIP Proxy or SIP Traffic Router

Personally I don’t think docker is a good container for pbxes, For multiple small clients on one machine, look to FusionPBX which is a gui front end to FreeSwitch, most simple components of a PBX are included , there is also a t38 fax server.

Perhaps best in your case, you can have multiple URLs all pointing to its IP and each client is totally separate, so reusing end point numbers is not a problem.

All of the provisioning and is stored in SQL ( postgres by default) so easily scriptable.

If you need more than that then add a cluster of dsiprouters (a simple gui in front of kamailio, a SIP proxy) before them.

1 Like

Hello @dicko Many thanks for your valuable tips :smiley:
I’m sure they’ll be useful.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.