sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
reboot
yum install wget gcc gcc-c++ ncurses-devel libxml2-devel sqlite-devel libuuid-devel openssl-devel screen lsof mlocate gnutls-devel kernel-devel subversion doxygen texinfo curl-devel net-snmp-devel neon-devel uuid-devel sqlite-devel sqlite git speex-devel gsm-devel
apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libiksemel-dev libiksemel-utils libiksemel3
pear uninstall db
pear install db-1.7.14
yum install libsrtp-devel
If libsrtp is not available in the repo install it from source.
cd /usr/local/src/
wget http://srtp.sourceforge.net/srtp-1.4.2.tgz
tar zxvf srtp-1.4.2.tgz
cd /usr/local/src/srtp
./configure CFLAGS=-fPIC
or
./configure --enable-pic --libdir=/usr/lib64
make && make install
or
git clone https://github.com/cisco/libsrtp.git
cd libsrtp/
autoconf
./configure CFLAGS=-fPIC --prefix=/usr
make
make runtest
make install
wget http://www.digip.org/jansson/releases/jansson-2.5.tar.gz
tar zxvf jansson-2.5.tar.gz
cd jansson-2.5
./configure --libdir=/usr/lib64
make & make install
Installing PJSIP
git clone https://github.com/asterisk/pjproject pjproject
cd pjproject
./configure --libdir=/usr/lib64 --prefix=/usr --enable-shared
--disable-sound --disable-resample --disable-video --disable-opencore-amr
--with-external-speex --with-external-srtp --with-external-gsm
make dep && make && make install
cd ..
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
cd /usr/src
tar xvfz dahdi-linux-complete-current.tar.gz
tar xvfz libpri-1.4-current.tar.gz
rm -f dahdi-linux-complete-current.tar.gz libpri-1.4-current.tar.gz
cd dahdi-linux-complete-*
make all
make install
make config
cd /usr/src/libpri-1.4.*
make
make install
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect
After selecting 'Save & Exit' you can then continue
make
make install
make config
ldconfig
Install Asterisk-Extra-Sounds
Installs the (8khz) 'wav' soundfiles and G722 (High Definition 'Wideband') audio.
mkdir -p /var/lib/asterisk/sounds
cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
git clone https://github.com/akheron/jansson.git
cd /usr/src/jansson
autoreconf -i
./configure
make
make install
wget http://www.pjsip.org/release/2.2.1/pjproject-2.2.1.tar.bz2
cd /usr/src
tar -xjvf pjproject-2.2.1.tar.bz2
cd pjproject-2.2.1
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound\
--disable-resample --disable-video --disable-opencore-amr
make dep
make
make install
Install Asterisk
cd /usr/local/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-13.0.0.tar.gz
tar zxvf asterisk*
cd /usr/local/src/asterisk*.
./configure --libdir=/usr/lib64
make menuselect
enable res_srtp
make && make install
make samples
make config
Running Asterisk
asterisk
asterisk -vvvr
And you get
localhost*CLI> core show version
DTLS
mkdir /etc/asterisk/keys
cd /usr/local/src/asterisk*/contrib/scripts
Create the DTLS certificates (replace pbx.mycompany.com with your ip address
or dns name, replace My Super Company with your company name)
./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys.
Install and Configure FreePBX
export VER_FREEPBX=12.0
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}
Now create the Asterisk user and set ownership permissions.
useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
rm -rf /var/www/html
A few small modifications to Apache.
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
service apache2 restart
Prepare MySQL
You now need to generate a secure password for FreePBX to use to talk to MySQL.
export ASTERISK_DB_PW=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 - | cut -c2-18`
That will generate a quasi-random 16 character long password, which should be secure enough for most things. If you had set the MySQL 'root' password to be something when you were installing the machine, you will need to add a -pyourpassword flag to the following lines
Configure Asterisk database in MYSQL.
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb
Set permissions on MYSQL database.
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"
Restart Asterisk and install FreePBX.
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
amportal a ma installall
amportal a reload
amportal chown
Finally, one last mod and start FreePBX.
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal start
Start FreePBX
Now FreePBX is installed,
firefox http://Address.Of.FreePBX.Server/admin
Astrisk command line and configuration
rasterisk
reload
sip reload
ps aux | grep asterisk
For sip.conf & extension.conf
context=inside -> for internal calls not recommended for a large number of users
odbc show
isql -v MySQL-asterisk
module show like odbc
cat /etc/asterisk/cdr.conf | grep -v '^;' | grep -v '^$'
cat /etc/asterisk/res_odbc.conf | grep -v '^;' | grep -v '^$'
vim /etc/asterisk/cdr.conf
/etc/init.d/asterisk restart
[span3pri]
exten => _50054XX,1,NoOp()
same => n,Set(CDR(accountcode)=pricall)
same => n,GotoIf($[${ODBC_ANIBLOCK(${CALLERID(number)})}]?busy)
same => n(dial),Dial(DAHDI/G1/${EXTEN})
same => n(busy),Busy(10)
same => n,Hangup
[ANIBLOCK]
dsn=telesys
readsql=SELECT IF(COUNT(1)>0, 1, 0) FROM Aniblock WHERE NUMBER='${ARG1}'
vim sip.conf
; sip.conf
; HOT DESK USERS
[0000FFFF0001]
type=friend
host=dynamic
secret=my_special_secret
context=hotdesk
qualify=yes
[0000FFFF0002]
type=friend
host=dynamic
secret=my_special_secret
context=hotdesk
qualify=yes
; END HOT DESK USERS
su - postgres
$ psql -U asterisk -h localhost asterisk
Password:
Then create the table with the following bit of SQL:
CREATE TABLE ast_hotdesk
(
id serial NOT NULL,
extension int8,
first_name text,
last_name text,
cid_name text,
cid_number varchar(10),
pin int4,
context text,
status bool DEFAULT false,
"location" text,
CONSTRAINT ast_hotdesk_id_pk PRIMARY KEY (id)
)
WITHOUT OIDS;
For MySQL:
$ mysql -u asterisk -p asterisk
Enter password:
Then create the table with the following bit of SQL:
CREATE TABLE ast_hotdesk
(
id serial NOT NULL,
extension int8,
first_name text,
last_name text,
cid_name text,
cid_number varchar(10),
pin int4,
context text,
status bool DEFAULT false,
location text,
CONSTRAINT ast_hotdesk_id_pk PRIMARY KEY (id)
);
A simple example follows. Suppose we have the following func_odbc.conf:
[ALL_AVAIL_EXTENS]
prefix=GET
dsn=asterisk-connector
mode=multirow
readsql=SELECT extension FROM ast_hotdesk WHERE status = '${ARG1}'
and a dialplan in extensions.conf that looks something like this:
[multirow_example]
exten => start,1,Verbose(1,Looping example)
same => n,Set(ODBC_ID=${GET_ALL_AVAIL_EXTENS(1)})
same => n,GotoIf($[${ODBCROWS} < 1]?no_rows,1)
same => n,Set(COUNTER=1)
same => n,While($[${COUNTER} <= ${ODBCROWS}])
same => n,Set(AVAIL_EXTEN_${COUNTER}=${ODBC_FETCH(${ODBC_ID})})
same => n,Set(COUNTER=$[${COUNTER + 1])
same => n,EndWhile()
same => n,ODBCFinish()
exten => no_rows,1,Verbose(1,No rows returned)
same => n,Playback(silence/1&invalid)
same => n,Hangup()
Here’s another extensions.conf example:
[multirow_example_2]
exten => start,1,Verbose(1,Looping example with break)
same => n,Set(ODBC_ID=${GET_ALL_AVAIL_EXTENS(1)})
same => n(loop_start),NoOp()
same => n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})})
same => n,GotoIf($["${ODBC_FETCH_RESULT}" = "FAILURE"]?cleanup,1)
same => n,GotoIf($["${ROW_RESULT}" = "1104"]?good_exten,1)
same => n,Goto(loop_start)
exten => cleanup,1,Verbose(1,Cleaning up after all iterations)
same => n,Verbose(1,We did not find the extension we wanted)
same => n,ODBCFinish(${ODBC_ID})
same => n,Hangup()
exten => good_exten,1,Verbose(1,Extension we want is available)
same => n,ODBCFinish(${ODBC_ID})
same => n,Verbose(1,Perform some action we wanted)
same => n,Hangup()
[PHONE_STATUS]
prefix=HOTDESK
dsn=asterisk
readsql=SELECT extension FROM ast_hotdesk WHERE status = '1'
readsql+= AND location = '${ARG1}'
If we try to dial a number that is not handled by our context (or one of the transitive contexts—i.e., international contains long distance, which also contains local), the built-in extension i is executed, which plays back a message stating that the action cannot be performed and hangs up the call:
[hotdesk_outbound]
exten => _X.,1,NoOp()
same => n,Set(LOCATION=${CUT(CHANNEL,/,2)})
same => n,Set(LOCATION=${CUT(LOCATION,-,1)})
same => n,Set(WHO=${HOTDESK_PHONE_STATUS(${LOCATION})})
same => n,GotoIf($[${ISNULL(${WHO})}]?no_outgoing,1)
same => n,Set(${WHO}_CID_NAME=${HOTDESK_INFO(cid_name,${WHO})})
same => n,Set(${WHO}_CID_NUMBER=${HOTDESK_INFO(cid_number,${WHO})})
same => n,Set(${WHO}_CONTEXT=${HOTDESK_INFO(context,${WHO})})
same => n,Goto(${${WHO}_CONTEXT},${EXTEN},1)
[international]
exten => _011.,1,NoOp()
same => n,Set(E=${EXTEN})
same => n,Goto(outgoing,call,1)
exten => i,1,NoOp()
same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
same => n,Hangup()
include => longdistance
[longdistance]
exten => _1NXXNXXXXXX,1,NoOp()
same => n,Set(E=${EXTEN})
same => n,Goto(outgoing,call,1)
exten => _NXXNXXXXXX,1,Goto(1${EXTEN},1)
exten => i,1,NoOp()
same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
same => n,Hangup()
include => local
[local]
exten => _416NXXXXXX,1,NoOp()
same => n,Set(E=${EXTEN})
same => n,Goto(outgoing,call,1)
exten => i,1,NoOp()
same => n,Playback(silence/2&sorry-cant-let-you-do-that2)
same => n,Hangup()
If the call is allowed to be executed, it is sent to the [outgoing] context for processing and the caller ID name and number are set with the CALLERID() function. The call is then placed via the SIP channel using the service_provider we created in the sip.conf file:
[outgoing]
exten => call,1,NoOp()
same => n,Set(CALLERID(name)=${${WHO}_CID_NAME})
same => n,Set(CALLERID(number)=${${WHO}_CID_NUMBER})
same => n,Dial(SIP/service_provider/${E})
same => n,Playback(silence/2&pls-try-call-later)
same => n,Hangup()
Our service_provider might look something like this in sip.conf:
[service_provider]
type=friend
host=switch1.service_provider.net
defaultuser=my_username
fromuser=my_username
secret=welcome
context=incoming
canreinvite=no
disallow=all
allow=ulaw
Now that we’ve implemented a fairly complex feature in the dialplan with the help of func_odbc to retrieve and store data in a remote relational database, hopefully you’re starting to get why we think this is so cool. With a handful of self-defined dialplan functions in the func_odbc.conf file and a couple of tables in a database, we can create some fairly rich applications!
; extconfig.conf
sippeers => driver,database[,table]
; extconfig.conf
sippeers => odbc,asterisk,ast_sipfriends
To also load our SIP users from the database, we would define the sipusers object like so:
sipusers => odbc,asterisk,ast_sipfriends
;IVR /etc/extension.conf
[aa_menu]
exten => s,1,Answer()
exten => s,n(menu_beginning) , Bckground(main-menu)
exten => s,n,WaitExten(5)
exten => s,n,Hangup()
exten => 1,1,Queue(sales)
exten => 2,1,Queue(support)
exten => 3,1,Directory()
exten => 0,1,Dial(Sip/phone-2) ; in touch with an operator
exten => i,1,Playback(invalid) ; when operator digit an unvalid number
exten => i,n,Goto(s,menu_beinning)
exten => t,1,Playback(vm-sorry) ; when operator doesn t digit anthing
exten => i,n,Goto(s,menu_beinning)
include => phones
Read()+ GotoIf
Text to Speech
-Cepstral
Automatic Speech Recognition(ASR)
-LumenVox
-Vestec
See and How to Install and Configure a Digium TE13x Single-Span T1/E1 Card
No comments:
Post a Comment