> MySQL & Asterisk (allow only enabled numbers to be dialled via MySQL)
> ------------------------------
>
> MySQL
> Create new database ⇒ db_asterisk
> $: mysql -u root -p
> $: Enter password: rootpassword123
> mysql> CREATE DATABASE db_asterisk;
>
> Create user & grant privileges to database for asterisk user
> $: mysql> CREATE USER 'userraj'@'%' IDENTIFIED BY 'userrajpassword123';
> $: mysql> GRANT ALL PRIVILEGES ON db_asterisk.* TO 'userraj'@'%';
>
> Update users privileges or reboot:
> $: mysql> FLUSH PRIVILEGES;
>
> Login using user “root”
> $: mysql -u root -p
> $: Enter password: rootpassword123
>
> Create table enabled numbers “tbl_enablednumbers”
> USE db_asterisk; <== choose a database
> $: mysql> CREATE TABLE tbl_enablednumbers (
> first_name varchar(30) NOT NULL default '',
> last_name varchar(30) NOT NULL default '',
> enabled_numbers varchar(20) NOT NULL default '' );
>
> Insert the default enabled number manually
> $: mysql> USE db_asterisk; <== choose a database
> $: mysql> INSERT INTO tbl_enablednumbers (first_name, last_name, enabled_numbers) VALUES (’Raj’,’Raj’,’012345678’);
>
> Display table entries.
> $: mysql> USE db_asterisk; <== choose a database
> $: mysql> SELECT * from tbl_enablednumbers; <== display all table entries
>
>
>
>
>
>
>
> Asterisk:
>
> $: sudo nano /etc/odbcinst.ini
> [MySQL]
> Description = ODBC for MySQL
> Driver = /usr/lib/i386-linux-gnu/odbc/
> Setup = /usr/lib/i386-linux-gnu/odbc/
> FileUsage = 1
>
> $: sudo nano /etc/odbc.ini
> [asterisk_mysql]
> Description = MySQL connection to 'db_asterisk' database
> Driver = MySQL
> Database = db_asterisk
> Server = localhost
> UserName = userraj
> Password = userrajpassword123
> Port = 3306
> Socket = /var/run/mysqld/mysqld.sock
>
> /etc/asterisk/res_odbc.conf
> [ASTERISK_test]
> enabled => yes
> dsn => asterisk_mysql
> username => userraj
> password => userrajpassword123
> pre-connect => yes
>
> /etc/asterisk/func_odbc.conf
> [ASTERISK_ENABLEDNUMBERS]
> dsn = ASTERISK_test
> readsql = SELECT * FROM tbl_enablednumbers WHERE enabled_numbers = ‘${ARG1}’
>
> /etc/asterisk/extensions.conf
> [pstn-incoming]
> exten=s,1,NoOp
> same=>n,GotoIf($[${ODBC_
> same=>n(allow),Answer
> same=>n(reject),Hangup
>
>
> Recompile Asterisk so that ODBC modules are created and installed:
> $: ~/src/asterisk-complete/
> $: sudo ./configure
> $: sudo make menuselect
> $: sudo make install
http://asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/getting_funky.html
No hay comentarios:
Publicar un comentario