MySQLSwitch

Requires:

The MySQL dev libs
A MySQL server (local or remote)

Introduction:

mysqlswitch provides a mechanism for reading extensions.conf directly from a MySQL database. What this means is your extensions.conf file only really needs to have the:
[general]

static=yes
writeprotect=yes
section (assuming you want to protect the dialplan) and that's it - the rest comes from the database. When compiled and installed mysqlswitch will do the following, in the following order when asterisk starts...


1. Search the db for, and create global variable definitions
2. Search the db for, and add contexts
3. Search the db for includes* and add them.
4. Add switch (MySQLSwitch) to each of those contexts (optional).
5. Search the db for includes* and add them.

When a number is dialled in an any these contexts mysqlswitch will do a live lookup in the database for what it should do. The db entry looks something like this,

* Includes can currently only be placed at the top or bottom of a context ie

[mycontext]

include => blah
switch=>MySQLSwitch
or
[mycontext]

switch=>MySQLSwitch
include => blah
this is indicated in the includes table, if the position field is 0 then the entry is at the top, if it is 1 then it's at the bottom.
Notes:

To add new globals variables from the db, you need to do a reload or restart asterisk.
To add new contexts from the db you need to do a reload or restart asterisk.
Macros are just like any other context and function normally.

Example data

Contexts:

name            description             switch
switch-test     Test Switch Context     1
switch-example  Testing some more       1
macro-cheesed   test macro              1
pooky           this one is disabled    0

Globals:

name            description             value           active
chickenpie      Test global var         SICKBAG         1

Includes:

targetcontext   includecontext  position
switch-example  switch-test     0

Dialplan:

context         exten   pri     app             data                            description

switch-test     s       1       NOOP            ${CHICKENPIE}                   Display variable
switch-test     t       1       Hangup

switch-example  _45XXX. 1       Wait            1

macro-cheesed   s       1       NOOP            ${ARG1} ${ARG2} ${ARG3}         Display vars in macro
macro-cheesed   s       2       Wait            1
macro-cheesed   s       3       Cepstral        Baa Baa Black Sheep
Todo:

Need to create pretty web interface to the data...

Building it:

1. Use mysqlswitch.sql to create your tables (you need to create the db first)
2. Modify the Makefile, change the paths at the top for your system, then do a make.
3. Modify mysqlswitch.conf to suit and copy to your /etc/asterisk/ dir
4. copy res_mysqlswitch.so to /var/lib/asterisk/modules/ (or where ever you keep them)
5. Restart asterisk.