Admins/Asterisk integration

From Tine 2.0 - Wiki

This documentation applies to Tine 2.0 2009-11 MS1 at least.

Theory of operation

The Voipmanager application allows you to manage sip peers, voicemail boxes and meetme rooms. These information get stored in Tine 2.0 database. Asterisk can access these informations either by using the mysql or curl realtime backend. Optional Tine 2.0 can also generate the needed configuration files and upload them to Asterisk.

Integrating Asterisk with Tine 2.0

Asterisk settings for config.inc.php

 'asterisk' =>
    array (
        'managerbaseurl' => 'http://asteriskmanagerhostname.domain:8088/asterisk',
        'managerusername' => 'managerusername',
        'managerpassword' => 'managerpassword',
    ),

Realtime Sippeers

MySQL

Create a view for Asterisk 1.6 in the Tine 2.0 database:

set names utf8;
create view `view_asterisk_sip_peers` AS select `tine20_asterisk_sip_peers`.*, `tine20_asterisk_context`.`name` AS `context` from `tine20_asterisk_sip_peers` join `tine20_asterisk_context` on `tine20_asterisk_sip_peers`.`context_id` = `tine20_asterisk_context`.`id`;

Create a view for Asterisk 1.4 in the Tine 2.0 database:

set names utf8;
create view `view_asterisk_sip_peers` AS select `tine20_asterisk_sip_peers`.*, `tine20_asterisk_sip_peers`.`defaultuser` as `username`, `tine20_asterisk_context`.`name` AS `context` from `tine20_asterisk_sip_peers` join `tine20_asterisk_context` on `tine20_asterisk_sip_peers`.`context_id` = `tine20_asterisk_context`.`id`;

Create a separate mysql account for Asterisk with access to the view created above only:

 grant select,update on DATABASENAME.view_asterisk_sip_peers to DATABASEUSERNAME@HOSTNAME_ASTERISK_SERVER identified by 'THESECRETPASSWORD';

Now you need to configure Asterisk to make use of the MySQL database. Add following lines to /etc/asterisk/res_mysql.conf:

[general] 
dbhost = MYSQL_HOSTNAME
dbname = DATABASENAME
dbuser = DATABASEUSERNAME
dbpass = THESECRETPASSWORD
dbport = 3306

Add following line to /etc/asterisk/extconfig.conf

sippeers => MYSQL_HOSTNAME,DATABASENAME,view_asterisk_sip_peers

Now reload the Asterisk configuration and you should be done.

CURL

Starting with version 1.6 Asterisk supports a curl based realtime backend. This way you can let Asterisk communicate with Tine 2.0 directly over HTTP and there is no need to give Asterisk direct access to the database.

Add following lines to the [globals] section in /etc/asterisk/extensions.conf:

[globals]
CURLOPT(userpwd)=TINE20USERNAME:TINE20PASSWORD

Username and password must be the credentials of an existing Tine 2.0 account with access to the Voipmanager application.

Add following lines to /etc/asterisk/extconfig.conf

sippeers => curl,http://TINE20WEBSERVER/index.php?method=Voipmanager_SipPeers.handleResConfig&action=
sipregs  => curl,http://TINE20WEBSERVER/index.php?method=Voipmanager_SipRegs.handleResConfig&action=

Now reload the Asterisk configuration and you should be done.