This is EXPERIMENTAL, use in a test environment, you get no support whatsoever

Export appleraisin branch from svn:

svn export http://svn.digium.com/svn/asterisk/team/group/edv-appleraisin-trunk/ appleraisin-trunk

Or, if you want to test this on Asterisk 1.8, just export db.c:

svn export http://svn.digium.com/svn/asterisk/team/group/edv-appleraisin-trunk/main/db.c

Overwrite existing db.c and do make, make install

Compile asterisk as usual, you MUST select res_mysql otherwise rest will fail.

Dump your current astdb with this command (NOTE! Only tested on FreePBX 2.9, YMMV)

/var/lib/asterisk/bin/dumpastdb.php myastdb

Edit asterisk.conf, add a systemname like this:

systemname=freepbxrulez

Create a table in asterisk database:

        CREATE TABLE `astdb` (
                `systemname` varchar(40) NOT NULL,
                `family` varchar(256) NOT NULL,
                `keyname` varchar(256) NOT NULL,
                `value` varchar(1050) NOT NULL,
                PRIMARY KEY  (`family`,`keyname`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

edit /etc/asterisk/modules.conf add the following at the top before the preload => :

load => res_realtime.so
load => res_config_mysql.so

edit /etc/asterisk/extconfig.conf, add this at the end:

astdb => mysql,general,astdb

Note the format for this line:

  • astdb = the name of the family to use in Asterisk, astdb to be used
  • mysql = the database engine
  • general = the name of the section in res_mysql.conf
  • astdb = the table name

Check your /etc/asterisk/res_mysql.conf that the section for the asterisk database is called general:

[general]
dbhost = 127.0.0.1
dbname = asterisk
dbuser = asteriskuser
dbpass = amp109
; NOTE! If running Asterisk 1.6 or later add the following line
requirements=warn

Start asterisk with amportal start, if you get errors, check your log.

Now, restore astdb from previous backup:

/var/lib/asterisk/bin/restoreastdb.php myastdb

Now, go to asterisk cli and type

database show

You will now see astdb entries, all read from mysql

Outstanding Issues

If you have a lot of entries in astdb (in my case around 2000) and if you do database show Asterisk will core
This is not the code in appleraisin but a memory issue in res_config_mysql.so
This is now duplicated and fixed in Asterisk trunk, see Asterisk issue 19090

Did I mentioned that this is EXPERIMENTAL, use in a test environment, you get no support whatsoever