OpenBTS: 2.8 Instalasi Real Time Asterisk

From OnnoWiki
Revision as of 09:39, 11 February 2012 by Onnowpurbo (talk | contribs) (New page: Asterisk Realtime Configuration Below are directions for getting Realtime working with Sqlite3 in Asterisk. It would be really sweet if someone wrote a script to do all of this! Cleaning...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Asterisk Realtime Configuration

Below are directions for getting Realtime working with Sqlite3 in Asterisk.

It would be really sweet if someone wrote a script to do all of this! Cleaning up prior install

sqlite3 and asterisk are both pulled in via Apt with the "simple" install. Make sure to remove those two packages to allow you to build new ones from source.

sudo apt-get remove asterisk sqlite3 sudo apt-get autoremove

Installing required software in the operating system

   Download sqlite3, available from the packages branch.
       configure, make, make install
       sqlite3 must be compiled with SQLITE_ENABLE_COLUMN_METADATA defined, so it's ./configure CFLAGS="-DSQLITE_ENABLE_COLUMN_METADATA -O2" 
   sudo apt-get install libsqlite3-dev
   If you are going to install Erlang anyway, do that now with apt-get install since it includes ODBC. Otherwise:
       download  unixODBC. This is available from the packages branch in SVN.
       configure, make, make install 
   download  sqliteodbc. This is available from the packages branch in SVN.
   configure, make, make install 

(Re)Building Asterisk

Note that if asterisk was already built, then after downloading the software above you need to redo

   ./configure --disable-xmldoc
   make menuselect
       Make sure Sqlite3 and ODBC are selected, especially in "applications", "resource modules" and "dialplan functions".
       Make sure "res_realtime" is selected in "resource modules".
       You should NOT see "XXX" on the Sqlite3 and ODBC selections anywhere in the configuration menus. If you see "XXX" for Sqlite3 or ODBC features anywhere, that means that those packages are not installed correctly (or at least in the way that Asterisk expects to see them). Look at the config.log file for clues.
           If you are building a full BTS unit, you will need to install Erlang with apt-get install and that will include an ODBC installation that Asterisk likes. 
   make
   make install 

Yes, you need to rebuild Asterisk. And if you are going to add Speex support, this would be the time to do it. You are supposed to be able to install Speex with apt-get install, but I have not gotten that to work yet. ODBC configuration files

   /etc/odbcinst.ini
   [SQLite3]
   Description=SQLite3 ODBC Driver
   Driver=/usr/local/lib/libsqlite3odbc.so
   Setup=/usr/local/lib/libsqlite3odbc.so
   Threading=2
   /etc/odbc.ini
   [asterisk]
   Description=SQLite3 database
   Driver=SQLite3
   Database=/var/lib/asterisk/sqlite3dir/sqlite3.db
   # optional lock timeout in milliseconds
   Timeout=2000

You will also need symbolic links to the files in the following places:

   /usr/local/etc/odbcinst.ini /usr/local/etc/odbc.ini
   /root/.odbcinst.ini /root/.odbc.ini
   ~openbts/.odbcinst.ini ~openbts/.odbc.ini 

In other words, as root:

cd /usr/local/etc; ln -s /etc/odbc.ini; ln -s /etc/odbcinst.ini
cd /root; ln -s /etc/odbc.ini .odbc.ini; ln -s /etc/odbcinst.ini .odbcinst.ini
cd ~openbts; ln -s /etc/odbc.ini .odbc.ini; ln -s /etc/odbcinst.ini .odbcinst.ini

You might also need symbolic links in the asterisk home directory if asterisk is running as user asterisk:

cd ~asterisk; ln -s /etc/odbc.ini .odbc.ini; ln -s /etc/odbcinst.ini .odbcinst.ini

The standard for configured BTS units is actually to put the real files in /usr/local/etc and then put symbolic links in:

   /etc
   ~root 

If Asterisk is running, modifying these files might make it crash. Be aware of that. Asterisk configuration files

   modules.conf 

Autoload must be enabled, plus make sure you're not overriding that by telling it NOT to load particular files, like res_config_odbc.so. The noload is commented out here.

[modules] autoload=yes

noload => res_config_odbc.so
   extconfig.conf 

This tells asterisk to use odbc for realtime sip. There was some confusion about whether the second field (asterisk, here) is the database, the odbc database handle, or the odbc context. I made them all the same to avoid figuring it out.

[settings] sipusers => odbc,asterisk,sip_buddies sippeers => odbc,asterisk,sip_buddies

   res_odbc.conf 

Standard odbc configuration. Everything named "asterisk" to avoid confusion.

[asterisk] enabled => yes dsn => asterisk pre-connect => yes

   func_odbc.conf 

This let's you use the function ODBC_SQL to execute any SQL statement in the dialplan. We use that to get the SIP number given the extension.

[SQL] dsn=asterisk readsql=${ARG1}

   extensions.conf 

Here's how the dialplan uses the ODBC_SQL function to get the SIP number from the extension. This is just here as an example, though. Use the extensions.conf file in openbts/trunk/AsteriskConfigs.

[phones]

This is the context for handsets provisioned through the realtime database.

exten => _N.,1,Set(Name=${ODBC_SQL(select dial from dialdata_table where exten = \"${EXTEN}\")}) exten => _N.,n,GotoIf($["${Name}" = ""] ?outbound-trunk,${EXTEN},1) exten => _N.,n,Set(IPAddr=${ODBC_SQL(select ipaddr from sip_buddies where name = \"${Name}\")}) exten => _N.,n,GotoIf($["${IPAddr}" = ""] ?outbound-trunk,${EXTEN},1) exten => _N.,n,Dial(SIP/${Name}@${IPAddr}:5062)

In this example, OpenBTS has it's inbound SIP interface at port 5062 and the context "outbound-trunk" is used for handling phones not provisioned in the realtime database. Sqlite3 database location

The default path for the Asterisk realtime database file is /var/lib/asterisk/sqlite3dir/sqlite3.db. (Note that this path was referenced above in /etc/odbc.ini.)

The sqlite3 database file must be readable and writable by asterisk, smqueue and sipauthserve, AND the directory in which the sqlite3 database file is located must ALSO be readable and writable by the applications. This is because sqlite3 generates temporary files in the directory.


Referensi

Pranala Menarik

Persiapan Hardware

OpenBTS 2.6

OpenBTS 2.8

Ettus E110

Lain Lain

Catatan Legal dan Pendukung

Catatan Sejarah