Exemple :
rasterisk -x "file convert /tmp/file_in.mp3 /tmp/file_out.gsm"
Ou via la commande sox :
FILE=my-file sox $FILE.wav -r 8000 -c1 $FILE.gsm lowpass 4000 compand 0.02,0.05 -60,-60,-30,-10,-20,-8,-5,-8,-2,-8 -8 -7 0.05
apt install libttspico-utils sox
pico2wave -l fr-FR -w /tmp/message.wav "[le texte de votre message]"
sox /tmp/message.wav -q -r 32000 -t raw /tmp/message.sln32
--- chan_sip.c.orig 2007-03-18 20:37:06.000000000 +0000 +++ chan_sip.c 2007-03-23 15:12:40.946029746 +0000 @@ -6890,7 +6890,7 @@ pidfnote = "On the phone"; break; case AST_EXTENSION_UNAVAILABLE: - statestring = "terminated"; + statestring = "confirmed"; local_state = NOTIFY_CLOSED; pidfstate = "away"; pidfnote = "Unavailable";
Source : http://forums.digium.com/viewtopic.php?f=1&t=78245&start=0 Repos de paquets Debian : http://debian.zionetrix.net/#asterisk
Pour l'appliquer proprement :
echo "export QUILT_PATCHES=debian/patches" > ~/.quiltrc cd /usr/local/src apt-get source asterisk apt-get install packaging-dev cd asterisk-~~~ quilt push -a quilt new fix_grandstream_blf_led quilt add channels/chan_sip.c vi channels/chan_sip.c # et faite la modif. quilt diff # Ca vous montre votre modif quilt refresh # met à jour le patch dhc # Met à jour le changelog debian dpkg-buildpackage # construction des paquets debian dans ../
Free accapare le port UDP 5004 (RTP) pour les freebox non-dégroupé (potentiellement les ports 5006 et 5008 également). Du coup il est impératif de modifier le port d'écoute RTP local du téléphone en 5010 par exemple.
On commence par mettre en place un compte IAX qui sera utilisé par iaxmodem pour se connecter à Asterisk. Pour cela on ajoute dans /etc/asterisk/iax.conf :
[fax1] type=friend secret=mypassword port=4570 host=dynamic context=internal disallow=all allow=ulaw requirecalltoken=no qualify=yes
On route ensuite dans le fichier /etc/asterisk/extentions.conf, les appels entrant sur un numéro vers le FAX :
[incoming] exten => 0102030405,1,Goto(fax-in,fax1) [fax-in] exten => fax1,1,Dial(IAX2/fax1) exten => fax1,n,Hangup()
On l'installe à partir du paquet Debian :
apt-get install iaxmodem
On créé ensuite une instance pour notre fax en créant un fichier /etc/iaxmodem/ttyIAX0 :
device /dev/ttyIAX0 owner uucp:uucp mode 660 port 4570 refresh 60 server 127.0.0.1 peername fax1 secret mypassword cidname My Company cidnumber 0102030405 codec ulaw
On lance le service :
/etc/init.d/iaxmodem start
A partir de la, un iax2 show peers dans la console d'asterisk devrait vous monter qu'iaxmodem est bien connecté.
On installe le serveur hylafax :
apt-get install hylafax-server
On met en place la configuration global dans le fichier /etc/hylafax/config :
#ContCoverPage: "etc/cover.templ" #DestControls: "etc/destctrls" #DialStringRules: "etc/dialrules" #QualifyCID: "etc/cid" #QualifyTSI: "etc/tsi" ServerTracing: 1 InternationalPrefix: 00 # ## AvantFAX # NotifyCmd: bin/notify.php
On met ensuite en place la configuration du modem dans le fichier /etc/hylafax/config.ttyIAX0 :
CountryCode: 33 AreaCode: 1 FAXNumber: +33.1.02.03.04.05 LongDistancePrefix: 0 InternationalPrefix: 00 DialStringRules: etc/dialrules ServerTracing: 1 SessionTracing: 11 RecvFileMode: 0600 LogFileMode: 0600 DeviceMode: 0600 RingsBeforeAnswer: 1 SpeakerVolume: off GettyArgs: "-h %l dx_%s" LocalIdentifier: "My Company" TagLineFont: etc/lutRS18.pcf TagLineFormat: "%%l|%c|Page %%P sur %%T" MaxRecvPages: 200 # # # Modem-related stuff: should reflect modem command interface # and hardware connection/cabling (e.g. flow control). # ModemType: Class1 # use this to supply a hint # # Enabling this will use the hfaxd-protocol to set Caller*ID # #ModemSetOriginCmd: AT+VSID="%s","%d" # # If "glare" during initialization becomes a problem then take # the modem off-hook during initialization, and then place it # back on-hook when done. # #ModemResetCmds: "ATH1\nAT+VCID=1" # enables CallID display #ModemReadyCmds: ATH0 Class1AdaptRecvCmd: AT+FAR=1 Class1TMConnectDelay: 400 # counteract quick CONNECT response # # If you have trouble with V.17 receiving or sending, # you may want to enable one of these, respectively. # #Class1RMQueryCmd: "!24,48,72,96" # enable this to disable V.17 receiving #Class1TMQueryCmd: "!24,48,72,96" # enable this to disable V.17 sending # # You'll likely want Caller*ID display (also displays DID) enabled. # ModemResetCmds: AT+VCID=1 # enables CallID display # # The pty does not support changing parity. # PagerTTYParity: none # # If you are "missing" Caller*ID data on some calls (but not all) # and if you do not have adequate glare protection you may want to # not answer based on RINGs, but rather enable the CallIDAnswerLength # for NDID, disable AT+VCID=1 and do this: # #RingsBeforeAnswer: 0 #ModemRingResponse: AT+VRID=1 # Uncomment DATE and TIME if you really want them, but you probably don't. #CallIDPattern: "DATE=" #CallIDPattern: "TIME=" CallIDPattern: "NMBR=" CallIDPattern: "NAME=" CallIDPattern: "ANID=" #CallIDPattern: "USER=" # username provided by call #CallIDPattern: "PASS=" # password provided by call #CallIDPattern: "CDID=" # DID context in call CallIDPattern: "NDID=" #CallIDAnswerLength: 4 # ## AvantFAX # FaxRcvdCmd: /var/spool/hylafax/bin/faxrcvd.php DynamicConfig: /var/spool/hylafax/bin/dynconf.php UseJobTSI: true
On redémarre le serveur Hylafax :
service restart hylafax
On installe les dépendances :
apt-get install libapache2-mod-php5 php5-cli imagemagick netpbm sudo php-mail php-mail-mime php-file php-db php5-mysql psutils wdiff rsync postfix php-net-smtp php-mdb2 php-mdb2-driver-mysql html2ps
On commence par préparer l'arborescence d’installation :
mkdir -p /var/www/empty /var/www/fax/upstream
Télécharger ensuite l'archive tar.gz du projet (je travaille ici avec la version 3.3.3) dans le dossier /var/www/fax/upstream. On extrait ensuite le contenu de l'archive dans le dossier /var/www/fax/avantfax-3.3.3 et on met en place le lien symbolique de la racine web :
cd /var/www/fax/ ln -s avantfax-3.3.3/avantfax public_html
On peut mettre en place ensuite le repos Apache dans le fichier /etc/apache2/sites-available/fax :
<VirtualHost *:80> ServerName fax.mycompany.com DocumentRoot /var/www/empty RedirectMatch ^(.*)$ https://fax.mycompany.com$1 ErrorLog /var/log/apache2/fax.mycompany.com.error.log CustomLog /var/log/apache2/fax.mycompany.com.access.log combined </VirtualHost> <VirtualHost *:443> ServerName fax.mycompany.com ServerAlias fax DocumentRoot /var/www/fax/public_html SSLEngine On ErrorLog /var/log/apache2/fax.mycompany.com.error.log CustomLog /var/log/apache2/fax.mycompany.com.access.log combined </VirtualHost>
On active ensuite ce VirtualHost :
a2ensite fax service apache2 reload
Réglons maintenant les privilèges des dossiers/fichiers d'avantfax :
cd /var/www/fax/avantfax-3.3.3/ chmod 0770 avantfax/includes/templates/admin_theme/templates_c/ avantfax/includes/templates/admin_theme/cache/ avantfax/includes/templates/main_theme/templates_c/ avantfax/includes/templates/main_theme/cache/ avantfax/tmp avantfax/faxes chmod 0755 avantfax/includes/faxcover.php avantfax/includes/faxrcvd.php avantfax/includes/notify.php avantfax/tools/update_contacts.php avantfax/tools/faxcover.php avantfax/includes/avantfaxcron.php avantfax/includes/dynconf.php chown -R www-data:www-data avantfax/ chown -R www-data:uucp avantfax/tmp avantfax/faxes
On met en place la base de données MySQL :
mysqladmin --default-character-set=utf8 --user='avantfax' --password='M1DBP@ss' create avantfax mysql --user='avantfax' --password='M1DBP@ss' avantfax < create_tables.sql
On ajoute le modem dans la base de données :
echo 'INSERT INTO Modems (device,alias,contact) VALUES ('ttyIAX0','My Company','fax@mycompany.com');'|mysql --user='avantfax' --password='M1DBP@ss' avantfax
On met en place les scripts utilisés par le serveur Hylafax :
ln -s /var/www/fax/public_html/includes/faxrcvd.php /var/spool/hylafax/bin/faxrcvd.php ln -s /var/www/fax/public_html/includes/dynconf.php /var/spool/hylafax/bin/dynconf.php ln -s /var/www/fax/public_html/includes/notify.php /var/spool/hylafax/bin/notify.php
On met en place la configuration sudo :
echo 'www-data ALL= NOPASSWD: /sbin/reboot, /sbin/halt, /usr/sbin/faxdeluser, /usr/sbin/faxadduser -u * -p *' > /etc/sudoers.d/avantfax chmod 0440 /etc/sudoers.d/avantfax
On met en place le cron :
echo '0 0 * * * www-data php /var/www/fax/public_html/includes/avantfaxcron.php -t 2' > /etc/cron.d/avantfax
Pour finir, on met en place le fichier de configuration. Pour cela, dans public_html/includes, on commence par copier le fichier local_config-example.php en local_config.php et on adapte :
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
Configuration : $AVANTFAX_DEBUG
Configuration $SENDFAX_USE_COVERPAGE à false.
Installation de tesseract :
apt-get install tesseract-ocr tesseract-ocr-fra
Configuration :
Prenons ici en exemple le log dans PostgreSQL :
CREATE TABLE "queue_log" ( "id" SERIAL, "time" TIMESTAMP WITHOUT TIME ZONE DEFAULT now() NOT NULL, "callid" character varying(50) NOT NULL, "queuename" character varying(50) NOT NULL, "agent" character varying(50) NOT NULL, "event" character varying(20) NOT NULL, "data1" character varying(50) NOT NULL, "data2" character varying(50) NOT NULL, "data3" character varying(50) NOT NULL, "data4" character varying(50) NOT NULL, "data5" character varying(50) NOT NULL, CONSTRAINT queue_log_pkey PRIMARY KEY (id) ) WITHOUT OIDS; GRANT ALL ON TABLE queue_log TO asterisk;
[general] dbhost=127.0.0.1 dbport=5432 dbname=asterisk dbuser=asterisk dbpass=astpass requirements=warn
queue_adaptive_realtime = yes
queue_log_to_file = yes
queue_log => pgsql,asterisk,queue_log
rasterisk -x reload
apt-get install asterisk-dahdi dahdi dahdi-linux dahdi-source module-assistant
m-a prepare
m-a a-i dahdi
service asterisk stop
modprobe dahdi
service asterisk start
exten => conference,1,MeetMe(,saMD)
exten => conference,1,MeetMe(,M)
Dans le fichier /etc/asterisk/extentions.conf :
[blacklisted] exten => s,1,Answer() exten => s,n,Wait(3) exten => s,n,Playback(tt-weasels) exten => s,n,Playback(/usr/share/asterisk/sounds/en/tt-monkeys) exten => s,n,Hangup()
exten => standard,1,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?blacklisted,s,1)
Via la cli asterisk (asterisk -r
) :
database show blacklist
database put blacklist 0171434150 "John Doe"
database del blacklist 0171434150
Il est aussi possible d'utiliser une petite interface web pour cela :
[general] enabled = yes port = 5038
[manage-blacklist] secret=secret write = system,command