asterisk – jucarii

Posted: November 26, 2008 in technical
Tags: ,

In vremurile (ne)bune pe cand lucram in BitDefender, ieseam cu echipa NP-UNIX in The Jack, unde stateam la discutii filosofice prelungite incercand sa nu imbatam prea tare bietul catel aciuat acolo.
Una din ideile principale era ca atunci cand te enervezi pe careva…sa te apuci sa-ti faci un server. Asta ar trebui sa te tina atent, cel putin o vreme, si sa nu te mai gandesti la personajul pe care ai dori sa-l torturezi in cele mai fancy idei care-ti trec prin creierash.

Ei, bine, tehnica asta a dus azi la re-invierea unui IVR mai vechi si ponosit…

Ingredientele sunt:

1. Una bucata Debian etch:

uname -a
Linux test01 2.6.18-6-686 #1 SMP Tue Jun 17 21:31:27 UTC 2008 i686 GNU/Linux

2. Una bucata Asterisk:

dpkg -l|grep asterisk
ii asterisk 1.2.13~dfsg-2etch4 Open Source Private Branch Exchange (PBX)
ii asterisk-app-dtmftotext 0.0.20060218-4 Text entry application for Asterisk
ii asterisk-classic 1.2.13~dfsg-2etch4 Open Source Private Branch Exchange (PBX) –
ii asterisk-config 1.2.13~dfsg-2etch4 config files for asterisk
ii asterisk-dev 1.2.13~dfsg-2etch4 development files for asterisk
ii asterisk-doc 1.2.13~dfsg-2etch4 documentation for asterisk
ii asterisk-sounds-extra 1.2.1-1 Additional sound files for the Asterisk PBX
ii asterisk-sounds-main 1.2.13~dfsg-2etch4 sound files for asterisk

3. Una bucata eyebeam .
Binenteles, telefonul trebuie configurat sa se inregistreze la asterisk:

ast1 ast2

Iar modalitatea de preparare este:

*fisierele de mai jos se gasesc in /etc/asterisk (by default):

1. fisierul sip.conf, in care mi-am definit contextul de lucru si utilizatorii centralei mele de SIP:

[general]
context=tutorial
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=yes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; tutorial
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; my users 😛
[cristina]
type=friend
username=cristina
callerid=cristina
secret=aiurea
host=dynamic
context=tutorial
mailbox=666@mb_tutorial

[alex]
type=friend
username=alex
callerid=alex
secret=aiurea
host=dynamic
context=tutorial
mailbox=777@mb_tutorial

[leti]
type=friend
username=leti
callerid=leti
secret=aiurea
host=dynamic
context=tutorial
mailbox=888@mb_tutorial

[ionut]
type=friend
username=ionut
callerid=ionut
secret=aiurea
host=dynamic
context=tutorial
mailbox=999@mb_tutorial

2. fisierul extensions.conf, sau dialplan-ul meu, logica de rutare a call-urilor:

[general]
static=yes
writeprotect=no
clearglobalvars=no

[globals]
CONSOLE=Console/dsp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; tutorial context
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[tutorial]
include => echotest
;exten => 1234,1,Macro(tutorial,SIP/${EXTEN},10)
exten => 1234,1,Dial(SIP/cristina,10)
exten => 1234,2,VoiceMail(666@mb_tutorial)
exten => 1234,3,PlayBack(vm-goodbye)
exten => 1234,4,Wait(2)
exten => 1234,5,HangUp()

exten => 1235,1,Dial(SIP/alex,10)
exten => 1235,2,VoiceMail(777@mb_tutorial)
exten => 1235,3,PlayBack(vm-goodbye)
exten => 1235,4,Wait(2)
exten => 1235,5,HangUp()

exten => 1236,1,Dial(SIP/leti,10)
exten => 1236,2,VoiceMail(888@mb_tutorial)
;exten => 1236,3,PlayBack(vm-goodbye)
;exten => 1236,4,Wait(2)
;exten => 1236,5,HangUp()

;exten => 1237,1,Dial(SIP,ionut,10)
;exten => 1237,2,VoiceMail(999@mb_tutorial)
;exten => 1237,3,PlayBack(vm-goodbye)
;exten => 1237,4,Wait(2)
;exten => 1237,5,HangUp()

;exten => s,1,Macro(tutorial,${EXTEN},SIP/${EXTEN})
;exten => s,1,Voicemail(@mb_tutorial)

[echotest]
exten => echo,1,Answer()
exten => echo,n,Set(TIMEOUT(absolute)=50)
exten => echo,n,Playback(tt-monkeys)
exten => echo,n,Echo()
exten => echo,n,System(echo “blabla” ${CUR})
exten => echo,n,Playback(tt-weasels)
exten => echo,n,HangUp()

3. fisierul voicemail.conf, in care am configul pentru serviciul de voicemail; am pus mai jos numai ce am adaugat eu pentru centrala mea:

[mb_tutorial]
666 => ttt,cristina,cristina@test01
777 => ttt,alex,alex@test01
888 => ttt,leti,leti@test01
999 => ttt,ionut,ionut@test01

4. Pentru ca vreau ca la pornirea centralei sa verific toate telefoanele definite in sip.conf, am creat un script micutz care suna la fiecare telefon in parte ca sa verifice daca acesta raspunde sau nu. “Sunatul” dinspre Asterisk l-am facut prin copierea in /var/spool/asterisk/outgoing/ a fisierelor cu informatiile specifice fiecarui telefon. Un “call-file” pentru cristina ar fi asta:

Channel: sip/cristina
Context:echotest
Extension:echo
Priority:1
Callerid:Automated Test System <>
SetVar: CUR=sip/cristina

5. iar scriptuletzul care-i suna pe useri (aici o suna numai pe cristina) este:

#! /bin/bash

cd /var/spool/asterisk;

for i in cristina ; do
#echo “Channel: $1/$i” >> echotest-$i.call;
#cat echotest.org.call >> echotest-$i.call;
#echo “SetVar: CUR=$1/$i” >> echotest-$i.call;
echo ” — Making echo test with $1/$i”;
cp call-files/echotest-$i.call outgoing/;chown -R asterisk:asterisk outgoing/
sleep 10;
done;

*La rularea scriptului (ca root, la mine nu a mers altfel) ar trebui ca userului cristina sa-i sune telefonul 😛 tadaaa…nu m-am bagat aici in meniuri de IVR, pentru configuri si informatii “advanced”, site-ul asterisk tips for IVR este foarte ok.

Advertisements
Comments
  1. ah…si inca ceva… Dap, clipul pe care il playaza userului este unul cu maimutze. Dar…care e pb daca userul aude in casti tipete de maimutze? maimutzele sunt dragute >:P ;))

  2. dst says:

    wtf? te lasi de blogging?

  3. dst, cine a zis ca ma las de blogging?

  4. kitty says:

    OK guys, da vad ca la posturile tehnice nu prea va ingramaditi….

  5. Grim.Gringo says:

    I love a little server build-up after supper.. 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s