8 posts / 0 new
Last post
olekaas's picture
Joined: 2007/11/02
Points: 0

I haven't foud a button on the dashboard that will propagate a new feature code to all tenants. With hundreds of tenants (or just more than 10), adding them manually is no fun and error prone. Luckily you can just pop the hood and get your hands dirty with grep, sed and diff:

Lets say you've made an awesome new script that all your tenant should have available through the same feature code (*74). Make a working copy:

cp /etc/asterisk/extensions.include .

Do not alter this copy. If you need to make changes, make a new copy. Next we want to make sure that no one is already using *74:

grep "exten => \*74" extensions.include

We need to escape the * with a \. If grep yields any results, resolve them before going any further. Either remap, delete or select another feature code. Next we are going to use sed. sed can find a pattern and append a line to it using the "a" modifier:

sed '/^\[feature-extensions-.*\]$/ a exten => *74,1,Macro(brew-coffee,no-cream) ; Let the user pour fresh coffee out of their handset' < extensions.include > wip

We search for the feature contexts [feature-extensions-TENANT]. Start and end of line is matched with ^ and $. The [ and ] must be escaped by prepending a \ and the tenant is matched with ".*" . After the "a" modifier the feature code definitions is appended.
We're almost there. Use diff to check if the extension.include file have been modified while we were hacking:

diff extensions.include /etc/asterisk/extensions.include

If diff yields any results - start over. Else stop webmin (or something), run diff again to be absolutely sure and move the modified file in to place:

mv wip /etc/asterisk/extensions.include

Reload asterisk and start webmin again. By strike of luck (if lack of skills) you should have en new feature code for all tenants.


thirdlane's picture
Joined: 2007/02/07
Points: 440

At some point I considered the “propagate” or “mass create/update” feature in PBX Manager (for both feature codes and outbound routes) – just did not have a chance to think it through. It probably should be available to the “root” only – could be quite dangerous.

I wonder what people think?

Alex Epshteyn
Third Lane Technologies
Multi Tenant Asterisk PBX

ci_newman's picture
Joined: 2009/03/04
Points: 0

For root access only, this could be quite a useful feature!

dozment's picture
Joined: 2007/11/20
Points: -10

YES!!!!! Please add it for features and outbound routes, Alex! That would be incredibly helpful.

dozment's picture
Joined: 2007/11/20
Points: -10

I just tried this for the first time. Very cool! Thanks, Ole! Would be nice to have it as a tool in the GUI or as a script. Could be very dangerous, though.

abongard's picture
Joined: 2009/04/06
Points: 0

very useful tool to have

George's picture
Joined: 2007/10/31
Points: 0


Any update on this feature..?


moshe's picture
Joined: 2008/11/30
Points: 10

Any idea using such a feature to propogate all the modifications needed to add for park when upgrating from 1.4 to 1.6