Asterisk extensions from mysql

There is a script in contrib/scripts called:
retrieve_extensions_from_mysql.pl

This can be used to write a file to be used to write out extensions.conf
- alternatively it can be used to create a subset which is #included into the main file

Create database:

CREATE TABLE extensions (
context CHAR(20) DEFAULT 'default' NOT NULL,
extension CHAR(20) NOT NULL,
priority INT(2) DEFAULT '1' NOT NULL,
application CHAR(20) NOT NULL,
args CHAR(50),
descr TEXT,
flags INT(1) DEFAULT '0' NOT NULL,
PRIMARY KEY(context, extension, priority)
);

CREATE TABLE globals (
variable CHAR(20) NOT NULL,
value CHAR(50) NOT NULL,
PRIMARY KEY(variable, value)
);

If flags is 1 then this record is not included in the output extensions file

The username specified in the file only needs to have SELECT priviliges on this database.

Asterisk needs to be reloaded after running this script in order to see the changes activated.

SQL example for macro-stdexten

INSERT INTO `bit_extensions` VALUES ('default', '_5XX', 1, 'Macro', 'stdexten,${EXTEN},${SIP${EXTEN}}', 'Dial internal extensions.', 0);
INSERT INTO `bit_extensions` VALUES ('default', '_5XX', 2, 'Hangup', '', 'Hangup', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's', 1, 'Dial', '${ARG2},20', 'Ring the interface, 20 seconds maximum', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's', 2, 'Goto', 's-${DIALSTATUS},1', 'Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-NOANSWER', 1, 'Voicemail', 'u${ARG1}', 'If unavailable, send to voicemail w/ unavail announce', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-NOANSWER', 2, 'Goto', 'default,s,1', 'If they press #, return to start', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-BUSY', 1, 'Voicemail', 'b${ARG1}', 'If busy, send to voicemail w/ busy announce', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-BUSY', 2, 'Goto', 'default,s,1', 'If they press #, return to start', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', ' _s-.', 1, 'Goto', 's-NOANSWER,1', 'Treat anything else as no answer', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 'a', 1, 'VoicemailMain', '${ARG1}', 'If they press *, send the user into VoicemailMain', 0);


Back to Asterisk configuration from database


There is a script in contrib/scripts called:
retrieve_extensions_from_mysql.pl

This can be used to write a file to be used to write out extensions.conf
- alternatively it can be used to create a subset which is #included into the main file

Create database:

CREATE TABLE extensions (
context CHAR(20) DEFAULT 'default' NOT NULL,
extension CHAR(20) NOT NULL,
priority INT(2) DEFAULT '1' NOT NULL,
application CHAR(20) NOT NULL,
args CHAR(50),
descr TEXT,
flags INT(1) DEFAULT '0' NOT NULL,
PRIMARY KEY(context, extension, priority)
);

CREATE TABLE globals (
variable CHAR(20) NOT NULL,
value CHAR(50) NOT NULL,
PRIMARY KEY(variable, value)
);

If flags is 1 then this record is not included in the output extensions file

The username specified in the file only needs to have SELECT priviliges on this database.

Asterisk needs to be reloaded after running this script in order to see the changes activated.

SQL example for macro-stdexten

INSERT INTO `bit_extensions` VALUES ('default', '_5XX', 1, 'Macro', 'stdexten,${EXTEN},${SIP${EXTEN}}', 'Dial internal extensions.', 0);
INSERT INTO `bit_extensions` VALUES ('default', '_5XX', 2, 'Hangup', '', 'Hangup', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's', 1, 'Dial', '${ARG2},20', 'Ring the interface, 20 seconds maximum', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's', 2, 'Goto', 's-${DIALSTATUS},1', 'Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-NOANSWER', 1, 'Voicemail', 'u${ARG1}', 'If unavailable, send to voicemail w/ unavail announce', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-NOANSWER', 2, 'Goto', 'default,s,1', 'If they press #, return to start', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-BUSY', 1, 'Voicemail', 'b${ARG1}', 'If busy, send to voicemail w/ busy announce', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 's-BUSY', 2, 'Goto', 'default,s,1', 'If they press #, return to start', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', ' _s-.', 1, 'Goto', 's-NOANSWER,1', 'Treat anything else as no answer', 0);
INSERT INTO `bit_extensions` VALUES ('macro-stdexten', 'a', 1, 'VoicemailMain', '${ARG1}', 'If they press *, send the user into VoicemailMain', 0);


Back to Asterisk configuration from database


Created by: flavour, Last modification: Thu 30 of Mar, 2006 (07:07 UTC) by iticory
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+