Hey Hey Check it out Custom Context module

[i]EDITED BY p_lindheimer:

NOTE: the proper place to get this and other custom modules is in the following location. If there are other modules not in this repository then we should be informed to get them there.

The repository represents contributed modules that are not supported by the project team but available and in the svn so that developers who contribute them have a place to maintain and update them:



Check this out
It looks sweet…works great under the RC1 have not loaded on true custom context box but I will soon…

One feature which was a bit lacking in asterisk/freePbx was the ability to easily create multiple tennants.
A number of improvements have been made.

  1. inbound routing based on zap channel - i used to have to hack it by putting each zap channel in its own context.
  2. authtype = database allows for dividing extension ranges
    the main problem for me was outbound routing…
    I wanted some extensions to dial out one route, and others out another route.
    I had to create a custom context for each, then place each in their own custom context, then include all of the contexts which they should have access to. This became a nuisance as each module added its own context to from-internal-additional which could not be included as it also contains outbuond-allroutes.
    The purpose of this module is to dynamically list all contexts included in any contexts you choose, and allow you to create custom contexts which can include any of these all without config editing.
    As an added bonus, I added a select list to the devices/extensions page to allow you to easily select any of your custom contexts to place the device in.
    I left this as minor just because I don’t want anyone getting upset at me, but for me, at least, this is a major relief. :slight_smile:

How did u install MYSQL??
Is MYSQL runinng?

From the file INSTALL in the freepbx source folder you should have

- mysqladmin create asterisk -p
- mysql --user root -p asterisk < /usr/src/freepbx<version>/SQL/newinstall.sql

Grant access to these two databases you just created

**Note the default mysql username/password is asteriskuser/amp109.
**If you change either of these, you will be prompted for them while running ./install below

- mysql --user root -p

	mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY 'amp109';
	Query OK, 0 rows affected (0.00 sec)

	mysql> GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY 'amp109';
	Query OK, 0 rows affected (0.00 sec)
	mysql> quit

The important part amportal.conf

Run /usr/src/AMP/apply_conf.sh after making changes to this file

AMPDBHOST: the host to connect to the database named ‘asterisk’


AMPDBUSER: the user to connect to the database named ‘asterisk’


AMPDBENGINE: the type of database to use


AMPDBPASS: the password for AMPDBUSER


I found installation and usage instructions here:


Hello All:

I have freepbx installed in another servers with no problem. I am trying to
install version 2.2.0 on this this fedora core 5 server but I am having an
issue with mysql. I have install all dependencies for freepbx and asterisk,
including mysql-client, unixodbc, mysql connector etc… Still no luck. I
have follow all the install instructions for the creation of the database
step by step several times. I have try to use the ./install_amp
–username=… No luck also… Any advice will be appreciated.


[[email protected] freepbx-2.2.0]# ./install_amp
Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Checking user…OK
Checking for /etc/amportal.conf…OK
Reading /etc/amportal.conf…OK
Checking for /etc/asterisk/asterisk.conf…OK
Reading /etc/asterisk/asterisk.conf…OK
Using asterisk as PBX Engine
Checking for Asterisk 1.2…OK
Checking for selinux…OK
Connecting to database…FAILED
Try running ./install_amp --username=user --password=pass (using your own
user and pass)
[FATAL] Cannot connect to database

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash

Amportal-users mailing list
[email protected]

Post generated using Mail2Forum (http://www.mail2forum.com)

Great addition! I installed it successfully… Many thanks…


Can someone please explain a couple of things for me.

What is the difference between the ‘Custom Contexts Admin’ page under tools and Custom Contexts under setup?

Here’s what I need to do.

The majority of my users direct dial to the outside world without limitation and without dialing a number first to get out. So the default setup is fine for them.

However I do have a few tenants who have multiple lines and need to dial 9 to get out so they can do interoffice dialing between their extensions.

I have a couple of tenants that want to passcode all long distance, operator assisted and information calls (411). The passcode needs to be unique per tenant.

Can someone help me with this?

Hey here you go
a install script for those are having problems with the file download and install


I’ve been waiting for this.
It simplifies permissions for trunks.

I really feel bad about this… but i must admit i don’t know how to install the module, or run the script, could i ask for assistance? many thanks

OK as the module is not a supported module and may never be

maybe you should not install it.

But the install would be as easy as using putty or go to the console and enter in wget http://www.pbx4pros.com/files/freepbx/customcontext.sh
press enter in a second the file will downloaded
now you would set the permissions on the file chmod 0777 customcontext.sh
and then run it ./customcontext.sh

then go into the module admin and find it click install,

This is just alittle something I dug up at the site nad it may or may not be in 2.3 I am told but it looks like a redo of the whole nine yards is coming by 3.0

What about freepbx 2.3.x ? I tried to install over it, but fails to work. Is planing a version for 2.3.x? Or exist another solution with the same functionality?

tnx in advance.

I just want to make a follow up on this custom module. I installed it on our client production system because they share the pbx between three companies. I got it working without problem on Trixbox + freepbx
I’m using it for outbound call routing. It permits me to have different “Outbound routes” for each company using the system. And each Outbound Routes are using a different Trunk.
Techncally each trunks are using the same T1 ZAP TDM card but they have different Outbound Caller ID.
The only problem I have, is that each and every Trunk that use my zap g0 are all called “Trunk ZAP/g0”.
So when I have to be careful when I choose the trunk associated with my Outbound Route. It works but they can’t be renamed with a useful name.

And for now E911 on our system is based on those Outbound Caller ID. One Outbound Caller ID per physical location (as a couple phones will be used over internet/fiber network).

Can you give me a description of how you got it installed in FreePBX 2.4 and a link to get the module. I tried downloading it from FreePBX and gzipping it but it won’t install.


Nevermind… Google is your best friend…lol

Hi when I add a custom context to an extension it work but when I reload the custom context is blank, can someone tell me why?

no help?


the drop-down box is just an entry shortcut, there is another field that actually shows the set (and saved) context.

where is this field? In the extension I can only see: Custom Context drop-down box just below mailbox

Alek -

Under in Extension/Device Options/Context. You actually have to type the name of the context you made.

Yes but this has nothing to do with the custom context module. On that drop down menu the option remains blank even if it’s in use.

Yes, it has everything to do with the custom context module. As rjenkinsgb pointed out, that drop box just fills in the context field under device options.

Custom context creates a context with the name you gave it, there is nothing different from the module creates than any other context in Asterisk extensions.conf (or any of the includes).

FreePBX does a great job of hiding Asterisk internals from the user. To use the custom context module effectively a basic understand of Asterisk extensions (not phone extensions) is required.

One of the best books on the subject is “Asterisk, The Future of Telephony”. You seem interested in acquiring a working knowledge of Asterisk and FreePBX, I highly recommend you either purchase the book or read it online (it’s available for free).

If you want to learn all the tricks from the developers themselves you should consider the Open Telephony Training in October (see link at the top of the page). If you decide to go I will see you there!