AMI UpdateConfig pjsip.conf


#1

I have a project where I need to add, remove, edit peers in pjsip.conf. I started off using PHP and then realized AMI supported updating config files through the UpdateConfig action. I’m able to delete and edit peers without issue but can’t seem to get adding working properly.

See my ami actions below but the problems I’m encountering are when the peer gets added, it adds to the end of the file but doesn’t put spaces between the contexts/categories. Not a show stopper but formatting looks terrible.

The other issue is with the below actions, for some reason the username and password get added to both the abc-defaults and the abc-defaults-auth categories which shouldn’t be added to the abc-defaults.

Any help would be appreciated.

Action: UpdateConfig
SrcFilename: pjsip.conf
DstFilename: pjsip.conf

Action-000000: NewCat
Cat-000000: abc6789
Options-000000: inherit='abc-defaults'

Action-000001: Append
Cat-000001: abc6789
Var-000001: set_var
Value-000001: CIDOUT=1234566789

Action-000002: Append
Cat-000002: abc6789
Var-000002: callerid
Value-000002: "The Dude" <6789>

Action-000003: Append
Cat-000003: abc6789
Var-000003: mailboxes
Value-000003: 6789@abc

Action-000004: Append
Cat-000004: abc6789
Var-000004: auth
Value-000004: abc6789

Action-000005: Append
Cat-000005: abc6789
Var-000005: aors
Value-000005: abc6789

Action-000006: NewCat
Cat-000006: abc6789
Options-000006: allowdups,inherit='abc-defaults-auth'

Action-000007: Append
Cat-000007: abc6789
Var-000007: username
Value-000007: abc6789

Action-000008: Append
Cat-000008: abc6789
Var-000008: password
Value-000008: theDudesPassword

Action-000009: NewCat
Cat-000009: abc6789
Options-000009: allowdups,inherit='abc-defaults-aor'

Here’s the desired formatting:

[abc6789](abc-defaults)
set_var = CIDOUT=1234566789
callerid = "The Dude" <6789>
mailboxes = 6789@abc
auth = abc6789
aors = abc6789

[abc6789](abc-defaults-auth)
username = abc6789
password = theDudesPassword

[abc6789](abc-defaults-aor)

But here’s what I get:

[abc6789](abc-defaults)
set_var = CIDOUT=8642996789
callerid = "The Dude" <6789>
mailboxes = 6789@abc
auth = abc6789
aors = abc6789
username = abc6789
password = theDudesPassword

[abc6789](abc-defaults-auth)
username = abc6789
password = theDudesPassword

[abc6789](abc-defaults-aor)

#2

Just noticed the formatting removed some text. Each context/category is supposed to have the template names in parenthesis.


#3

To follow up on my own posting, I started looking at using the pjsip_wizard.conf which seems promising and would be less to write using AMI, but I don’t see one specific option that I need to create my PJSIP peer which is mailboxes=@context. Am I missing a setting somewhere or is this the case?


#4

After some trial and error I figured out that I can add the mailboxes variable by adding endpoint/mailboxes = 1234@abc.


#5

The PJSIP configuration wasn’t really written or designed with the AMI UpdateConfig in mind, so due to the way that some things are named (category names) it may not work as needed.