Page 299 - Asterisk™: The Future of Telephony
P. 299
musiconhold.conf | general | directory | /var/lib/asterisk/moh
(2 rows)
And now, there’s just one last thing to modify in the extconfig.conf file in /etc/asterisk
directory to tell Asterisk to get the data for musiconhold.conf from the database. Add
the following line to the end of the extconfig.conf file, then save it:
musiconhold.conf => odbc,asterisk,ast_config
Then connect to the Asterisk console and perform a reload:
*CLI> module reload
You can now verify that we have our music-on-hold classes loading from the database
by running moh show classes:
*CLI> moh show classes
Class: general
Mode: files
Directory: /var/lib/asterisk/moh
And there you go; musiconhold.conf loaded from the database. You can perform the
same steps in order to load other flat files from the database!
Dynamic Realtime
The dynamic realtime system is used to load objects that may change often: SIP/IAX2
users and peers, queues and their members, and voicemail. Since this information in
the system may either be changing or new records are being added on a regular basis,
we can utilize the power of the database to let us load this information on an as-needed
basis.
All of realtime is configured in the /etc/asterisk/extconfig.conf file, but dynamic realtime
has well-defined configuration names such as sippeers. Defining something like SIP
peers is done with the following format:
; extconfig.conf
sippeers => driver,database[,table]
The table name is optional, in which case Asterisk will use the predefined name (i.e.,
sippeers) as the table to look up the data. In our example, we’ll be using the ast_sip
peers table to store our SIP peer information.
Remember that we have both SIP peers and SIP users; peers are end-
points we send calls to, and a user is something we receive calls from.
A friend is shorthand that defines both.
So to configure Asterisk to load all SIP peers from a database using realtime, we would
define something like:
Using Realtime | 271