How do i add category [1001](+type=extension) using AMI?

I am using php’s PAMI client. I can’t figure out a way to add (+type=extension) to a category as i am using freepbx and i have to over ride some settings in pjsip.endpoint_custom_post.conf file. I just need to find out how to add to existing section using AMI as described in the docs below.

https://docs.asterisk.org/Fundamentals/Asterisk-Configuration/Asterisk-Configuration-Files/Adding-to-an-existing-section/

you need to ask on the frepbx forum, as we do not know how to overwrithe there config

There is no such file included in, or referenced by, an out of the box Asterisk system. This is probably referring to something used by FreePBX.

Also, I have never come across type=extension as a modifier.

“post” in the FreePBX naming system means that it is included after the FreePBX generated contents and affects how conflicts between that content and the user content are handled (I’d have to check the exact rules). Anything you add by AMI, other than by having it upload a .conf file, will be processed after the FreePBX generated code. + means that it amending a context that already exists, rather than adding one with a duplicate name.

Note that with AMI, your are either replacing the whole file, or you are modifying internal data structures, that have been created from the .conf files, but now reflect the consolidated overrides in those files. Any changes made will be lost on a restart.

To most accurately implement the sort of thing that such files do, you would need to work out what your contents means in terms of DialPlanExtensionAdd and DialplanExtensionRemove operations. Note that you cannot create symbolic names for priorities, this way; you must work out the absolute priority number.

You can also manipulate the .conf file, and the reload the configuration. Start at CreateConfig - Asterisk Documentation although I haven’t read this carefully enough to know all the catches.

The FreePBX custom files are user edited, although, of course, you need to understand the internals of their dialplan, if you change anything, and, in particular, it is only essential to use a post file if you are overriding something they have created, but you would need to know that in order to customise using the .conf file, rather than directly manipulating the running configuration. (If adding a new internal extension, that was otherwise implemented without reference to the FreePBX environment) you might only need to know to use the from-internal context.)

Sorry for the confusion. I am just trying to figure out a way to use AMI to add to an existing section like asterisk mentions in the docs. For overriding a previously defined section you would have to do
[section-name](+type=something)

https://docs.asterisk.org/Fundamentals/Asterisk-Configuration/Asterisk-Configuration-Files/Adding-to-an-existing-section/

The mechanism that is described there is processed at the time the file is read in. You are trying to do it after the file and its initial parse have been discarded in favour of modifying the internal content. Generally you need to use operations that directly modify the final internal representation, or you need to write a .conf file and reload. I think FreePBX does the latter, when you use its apply config operation.

I think chan_pjsip is the only one that uses type=*. but there are no AMI actions to directly manipulate it, and UpdateConfig wasn’t designed to support it, either.

It also looks to me as though update_config is intended to take a top level file as input, and, I strongly suspect, to resolve all #includes, as it looks, like + and type=modifiers are handled when update_config is run, not at reload time. If so, it would imply overwriting files that are owned by FreePBX, which will break FreePBX.

I suppose it is just possible that they would be copied from an inherits= setting, but even that might be a feature, rather than intended behaviour. The easiest way, to find out, would probably be to experiment.

The chances of finding anyone who has used updateconfig in anger is very low.

I suspect the main user of updateconfig is SwitchVox, not end users.

I think the only option open for chan_pjsip is to physically write the custom .conf file, then do a reload, which is what I think FreePBX does with the additional files, but probably without using AMI.

It looks like the processing of #include may simply be broken:

https://asterisk-users.digium.narkive.com/fk0bcpLJ/ami-manageraction-updateconfig-on-file-with-include-may-corrupt-the-file

and it is not at all clear how + and type= are handled in inherits, and in matching contexts.

Whilst it might be used for SwitchVox, it appears that it was used by the, late, AsteriskGUI. AsteriskGUI, I think, predated type= and, I suspect, had no need to handle + in .conf files.

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