Asterisk Realtime ConfigurationBelow 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 installsqlite3 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
(Re)Building AsteriskNote that if asterisk was already built, then after downloading the software above you need to redo
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
You will also need symbolic links to the files in the following places:
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:
If Asterisk is running, modifying these files might make it crash. Be aware of that. Asterisk configuration files
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
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
Standard odbc configuration. Everything named "asterisk" to avoid confusion. [asterisk] enabled => yes dsn => asterisk pre-connect => yes
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}
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 locationThe 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. 注:sqlie3ODBC(原文出处,翻译整理仅供参考!) |