Установка Asterisk 1.6 и FreePBX в Gentoo

В этой статье я опишу установку * и FreePBX в Gentoo. Если Вы еще не поставили Gentoo, то пора уже сделать это. Прочитайте статью «Установка Gentoo«.

Настраиваем portage для установки нужных пакетов с нужными ключами:

cat >>/etc/portage/package.keywords <<end-of-text
net-misc/asterisk ~x86
net-misc/asterisk-addons ~x86
media-libs/spandsp ~x86
net-misc/iaxmodem ~x86
net-libs/libpri ~x86
net-misc/dahdi ~x86
net-misc/dahdi-tools ~x86
end-of-text
cat >>/etc/portage/package.unmask <<end-of-text
net-misc/asterisk
net-misc/dahdi
net-misc/dahdi-tools
net-libs/libpri
end-of-text
cat >>/etc/portage/package.use <<end-of-text
dev-lang/php cli cgi apache2 pcre mysql iconv session unicode ctype bcmath bzip2 curl discard-path force-cgi-redirect ftp gd mhash posix sharedext sockets spell tidy tokenizer truetype xml xmlreader xmlwriter xmlrpc xpm zip xsl imap simplexml
media-libs/gd jpeg png truetype xpm
app-portage/layman subversion
media-libs/speex ogg
net-misc/asterisk dahdi mysql span speex
net-misc/asterisk-addons mysql mysql_loguniqueid
media-libs/tiff jbig jpeg
media-sound/sox encode ffmpeg libsamplerate mad sndfile wavpack
media-video/ffmpeg gsm
net-misc/hylafax jbig
end-of-text

Настраиваем фаирвол:

cat > /var/lib/iptables/rules-save <<end-of-text
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
:bad-packets - [0:0]
:icmp-allow - [0:0]
:sshguard - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -j sshguard
-A INPUT -j bad-packets
-A INPUT -p icmp -j icmp-allow
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp -m tcp --dport ssh -j ACCEPT
-A INPUT -p tcp -m tcp --dport http -j ACCEPT
-A INPUT -p tcp -m tcp --dport 4445 -j ACCEPT
-A INPUT -p udp -m udp --dport 5060 -j ACCEPT
-A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 32768:61000 -m state --state NEW -j ACCEPT
-A INPUT -p udp -m udp --dport 32768:61000 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p udp -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -j DROP
-A FORWARD -p icmp -j icmp-allow
-A FORWARD -j bad-packets
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -j ACCEPT
-A bad-packets -p tcp -m tcp --dport 445 -j DROP
-A bad-packets -p tcp -m tcp --dport 135 -j DROP
-A bad-packets -p tcp -m tcp --dport 137:139 -j DROP
-A bad-packets -p udp -m udp --dport 137:139 -j DROP
-A bad-packets -d 169.254.0.0/16 -j DROP
-A bad-packets -s 169.254.0.0/16 -j DROP
-A bad-packets -d 127.0.0.1/32 -j DROP
-A bad-packets -s 127.0.0.1/32 -j DROP
-A icmp-allow -p icmp -m icmp --icmp-type 8 -j RETURN
-A icmp-allow -p icmp -m icmp --icmp-type 0 -j RETURN
-A icmp-allow -p icmp -m icmp --icmp-type 4 -j RETURN
-A icmp-allow -p icmp -m icmp --icmp-type 3 -j RETURN
-A icmp-allow -p icmp -m icmp --icmp-type 11 -j RETURN
-A icmp-allow -p icmp -m icmp --icmp-type 12 -j RETURN
-A icmp-allow -j DROP
COMMIT
*nat
 :P REROUTING ACCEPT [0:0]
 :P OSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
end-of-text

/etc/init.d/iptables restart

Устанавливаем менеджер оверлеев

emerge -a layman && layman -L && layman -a voip && echo "source /usr/portage/local/layman/make.conf" >>/etc/make.conf

Устанавливаем необходимые пакеты

emerge -a dev-db/mysql apache mod_auth_mysql php PEAR-DB asterisk asterisk-addons iaxmodem hylafax sox dahdi-tools

На момент написания статьи пакет dahdi был версии 2.1.0.4 и собранный им модуль ядра dahdi_dummy не хотел грузиться с ошибками:

dahdi_dummy: Unknown symbol rtc_register
dahdi_dummy: Unknown symbol rtc_unregister
dahdi_dummy: Unknown symbol rtc_control

Поэтому я установил поверх портеджа более свежую версию dahdi-linux из исходников:

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-2.2.0-rc5.tar.gz
tar zxvf dahdi-linux-2.2.0-rc5.tar.gz ; cd dahdi-linux-2.2.0-rc5 ; make install ; modprobe -v dahdi_dummy
rc-update add dahdi default ; dahdi_genconf ; /etc/init.d/dahdi start
sed -i -e "s#;internal_timing#internal_timing#g" /etc/asterisk/asterisk.conf
cat >> /etc/modules.autoload.d/kernel-2.6 <<end-of-text
dahdi
dahdi_dummy
end-of-text

Немного настраиваем apache и mysql, а также включаем поддержку ISO-8859-5 (нужна для перевода FreePBX):

sed -i -e 's#ServerSignature On#ServerSignature Off#g' -e 's#\#EnableMMAP off#EnableMMAP on#g' -e 's#\#EnableSendfile off#EnableSendfile on#g' /etc/apache2/modules.d/00_default_settings.conf
sed -i -e 's#<IfModule negotiation_module>#<IfModule negotiation_module>\nDefaultLanguage ru\nAddDefaultCharset utf-8#' /etc/apache2/modules.d/00_languages.conf
sed -i -e 's#^User apache#User asterisk#g' -e 's#^Group apache#Group asterisk#g' /etc/apache2/httpd.conf
sed -i -e 's#^APACHE2_OPTS="#APACHE2_OPTS="-D AUTH_MYSQL #g' /etc/conf.d/apache2
sed -i -e 's#^log-bin#\#log-bin#g' /etc/mysql/my.cnf
sed -i -e "s#^magic_quotes_gpc = On#magic_quotes_gpc = Off#" /etc/php/apache2-php5/php.ini
rc-update add apache2 default ; rc-update add mysql default ; /etc/init.d/apache2 start
/usr/bin/mysql_install_db ; /etc/init.d/mysql start ; mysql_secure_installation
echo "en_US ISO-8859-1" >> /etc/locale.gen && echo "ru_RU.KOI8-R KOI8-R" >> /etc/locale.gen && echo "ru_RU.UTF-8 UTF-8" >> /etc/locale.gen && echo "ru_RU ISO-8859-5" >> /etc/locale.gen ; locale-gen

Теперь качаем и устанавливаем FreePBX (не забываем поменять стандартные пароли на какие-нить другие, например можно их сгенерировать командочкой openssl rand 8 -base64):

cd /usr/src && wget http://mirror.freepbx.org/freepbx-2.5.1.tar.gz && tar zxvf freepbx-2.5.1.tar.gz && cd freepbx-2.5.1
mysqladmin create asteriskcdrdb -p
mysqladmin create asterisk -p
mysql -p asteriskcdrdb <./SQL/cdr_mysql_table.sql
mysql -p asterisk <./SQL/newinstall.sql
mysql -p -e "GRANT ALL ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'some_password';"
mysql -p -e "GRANT ALL ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'some_password';"
/etc/init.d/asterisk start && ./install_amp

Должен появиться диалог установки FreePBX, примерно такой:

Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
Checking user..OK
Checking if Asterisk is running..running with PID: 29457..OK
Checking for /etc/amportal.conf../etc/amportal.conf does not exist, copying default
Creating new /etc/amportal.conf
Enter your USERNAME to connect to the 'asterisk' database:
 [asteriskuser]
Enter your PASSWORD to connect to the 'asterisk' database:
 [amp109] some_password
Enter the hostname of the 'asterisk' database:
 [localhost]
Enter a USERNAME to connect to the Asterisk Manager interface:
 [admin]
Enter a PASSWORD to connect to the Asterisk Manager interface:
 [amp111] some_other_password
Enter the path to use for your AMP web root:
 [/var/www/html]
/var/www/localhost/htdocs
Enter the IP ADDRESS or hostname used to access the AMP web-admin:
 [xx.xx.xx.xx] pbx.lansp.ru
Enter a PASSWORD to perform call transfers with the Flash Operator Panel:
 [passw0rd]
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]?
 [extensions]
Enter directory in which to store AMP executable scripts:
 [/var/lib/asterisk/bin]
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts:
 [/usr/local/sbin]
...
installed
Please update your modules and reload Asterisk by visiting http://pbx.lansp.ru/admin

*************************************************************************
* Note: It's possible that if you click the red 'Update Now' bar BEFORE *
* updating your modules, your machine will start dropping calls. Ensure *
* that all modules are up to date BEFORE YOU CLICK THE RED BAR. As long *
* as this is observed, your machine will be fully functional whilst the *
* upgrade is in progress.                                               *
*************************************************************************

В связи с особенностями vixie-cron инсталлятор не может добавить задания для FreePBX, мы сделаем это самостоятельно + добавим задание для автоматической очистки каталога, в котором хранятся записи, чтобы в нем хранились записи только за последние 30 дней:

crontab -u asterisk -e

24 * * * * /var/lib/asterisk/bin/freepbx-cron-scheduler.php
 1 4 * * * find /var/spool/asterisk/monitor -type f -mtime +31 | xargs rm -f

Cтартуем панель и добавляем ее в автозагрузку:

amportal kill ; amportal start && echo "/usr/local/sbin/amportal start" >> /etc/conf.d/local.start

Идем на http://pbx.lansp.ru/admin/config.php и сразу обновляем модули: Module Admin -> Check for updates online. Жмем Upgrade All, затем Process. После обновления еще раз жмем Check for updates online и устанавливаем желаемые модули. Я поставил следующие: freepbx_modules

Если какого-то модуля нет в стандартных – поищите в FreePBX Third-Party Unsupported Modules.

Внимание! После установки модуля Dialplan injection необходимо создать две дополнительные таблицы, инсталлятор модуля их не создает:

mysql -p asterisk

CREATE TABLE IF NOT EXISTS `dialplaninjection_dialplaninjections` (
  `id` int(11) NOT NULL auto_increment,
  `description` varchar(100) NOT NULL default '',
  `destination` varchar(250) NOT NULL default '',
  `exten` varchar(10) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `description` (`description`),
  UNIQUE KEY `exten` (`exten`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

--
-- Table structure for table `dialplaninjection_module`
--

CREATE TABLE IF NOT EXISTS `dialplaninjection_module` (
  `id` varchar(50) NOT NULL default '',
  `value` varchar(100) NOT NULL default '',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT IGNORE INTO `dialplaninjection_module` VALUES ('modulerawname', 'dialplaninjection');
INSERT IGNORE INTO `dialplaninjection_module` VALUES ('moduledisplayname', 'Dialplan Injection');
INSERT IGNORE INTO `dialplaninjection_module` VALUES ('moduleversion', '0.1.1');

После установки и обновления всех модулей жмем оранжевую кнопку Apply Configuration Changes.

Идем в Administrators и заводим администраторов, меняем пароль для admin. Теперь идем в General Settings и пишем Call recording format: «gsm», Recording Location: «/var/spool/asterisk/monitor/», Extension of fax machine for receiving faxes: «disabled», Country Indications: «Russia / ex Soviet Union». Жмем Submit Changes и затем оранжевую кнопку.

Немного донастраиваем нашу систему:

cat > /var/www/localhost/htdocs/panel/.htaccess <<end-of-text
AuthBasicAuthoritative  Off
AuthName                "FreePBX Administration"
AuthType                Basic
AuthUserFile            /dev/null

AuthMySQLUser           asteriskuser
AuthMySQLPassword       some_password
AuthMySQLDB             asterisk
AuthMySQLUserTable      ampusers
AuthMySQLNameField      username
AuthMySQLPasswordField  password
AuthMySQLPwEncryption   none

require                 valid-user
end-of-text

sed -i -e 's#$ARI_ADMIN_PASSWORD ="ari_password#$ARI_ADMIN_PASSWORD ="some_other_password#g' /var/www/localhost/htdocs/recordings/includes/main.conf.php
sed -i -e 's#AUTHTYPE=none#AUTHTYPE=database#g' /etc/amportal.conf
echo "language=ru" >> /etc/asterisk/sip_general_custom.conf
echo "LANGUAGE=ru" >> /etc/asterisk/globals_custom.conf
for i in /etc/asterisk/*.conf ; do sed -i -e "s#^;language=en#language=ru#g" $i; done

cat > /etc/logrotate.d/asterisk <<end-of-text
/var/log/asterisk/messages /var/log/asterisk/*log /var/log/asterisk/debug /var/log/asterisk/console /var/log/asterisk/full {
    create 0640 asterisk asterisk
    daily
    missingok
    nocompress
    rotate 32
    sharedscripts
    postrotate
        /usr/sbin/asterisk -rx 'logger reload' >/dev/null 2>/dev/null || true
    endscript
}
end-of-text

cd /etc/asterisk ; patch -p0 << end-of-text
--- modules.conf        2009-06-01 14:43:07.000000000 +0400
+++ /tmp/modules.conf   2009-06-01 16:13:07.000000000 +0400
@@ -34,11 +34,11 @@
;load => format_ogg_vorbis.so
load => format_wav.so
load => format_pcm.so
-load => format_au.so
+;load => format_au.so
; This isn't part of 'asterisk' iteslf, it's part of asterisk-addons. If this isn't
; installed, asterisk will fail to start. But it does need to go here for native MOH
; to work using mp3's.
-load => format_mp3.so
+;load => format_mp3.so
load => res_musiconhold.so
;
; Load either OSS or ALSA, not both
@@ -50,4 +50,18 @@
; Module names listed in "global" section will have symbols globally
; exported to modules loaded after them.
;
+
+load => res_monitor.so
+noload => cdr_custom.so
+noload => cdr_manager.so
+noload => cdr_csv.so
+;noload => chan_iax2.so
+noload => chan_mgcp.so
+noload => chan_phone.so
+noload => chan_skinny.so
+noload => chan_unistim.so
+noload => pbx_dundi.so
+noload => res_config_mysql.so
+noload => res_phoneprov.so
+
[global]
end-of-text

mkdir /var/lib/asterisk/mohmp3/none
amportal stop ; amportal kill ; amportal start

Для приема и отправки факсов настроим iaxmodem и hylafax. Сначала создадим в FreePBX экстеншн типа IAX2:

User Extension: 777
Display Name:   fax2email
secret:         some_iax_secret
port:           4570

Теперь конфигурируем iaxmodem:

cat >/etc/iaxmodem/default <<end-of-text
device      /dev/ttyIAX
owner       uucp:uucp
mode        660
port        4570
refresh     60
server      127.0.0.1
peername    392
secret      some_iax_secret
cidname     OOO CSIT
cidnumber   84965499057
codec       alaw
end-of-text

rc-update add iaxmodem default ; /etc/init.d/iaxmodem start

Конфигурируем hylafax:

cat >> /etc/inittab <<end-of-text
# hylafax
f0:2345:respawn:/usr/sbin/faxgetty ttyIAX
end-of-text

telinit q

cat >/etc/cron.d/hylafax.cron <<end-of-text
0 * * * *       root    /usr/sbin/faxqclean
25 23 * * *     root    sh /usr/sbin/faxcron | mail FaxMaster
end-of-text

Запускаем faxsetup и отвечаем на вопросы примерно так:

Setup program for HylaFAX (tm) 4.4.4.

Created for i686-pc-linux-gnu on Mon Jun  1 16:34:43 MSD 2009.

Found uuencode encoder: /usr/bin/uuencode
Found base64 encoder: /usr/bin/mimencode
Found Quoted-Printable encoder: /usr/bin/mimencode -q
Looks like /usr/bin/mimencode supports base64 encoding.
Found mimencode for compatibilty: /usr/bin/mimencode
Checking system for proper client configuration.
Checking system for proper server configuration.

Warning: /usr/share/ghostscript/8.64/Resource/Font does not exist or is not a directory!

The directory /usr/share/ghostscript/8.64/Resource/Font does not exist or this file is not a directory.
This is the directory where the HylaFAX client applications expect to
locate font metric information to use in formatting ASCII text for
submission as facsimile.  Without this information HylaFAX may generate
illegible facsimile from ASCII text.

Make /var/spool/fax/bin/ps2fax a link to /var/spool/fax/bin/ps2fax.gs.

Make /var/spool/fax/bin/pdf2fax a link to /var/spool/fax/bin/pdf2fax.gs.

There does not appear to be an entry for the FaxMaster either in
the YP/NIS database or in the /etc/aliases file.  The
FaxMaster is the primary point of contact for HylaFAX problems.
The HylaFAX client-server protocol server identifies this alias as
the place to register complaints and HylaFAX directs automatic mail
messages to this user when problems are identified on a server
machine or when the routine server maintainence scripts are run
(e.g. faxcron).

Should an entry be added for the FaxMaster to /etc/aliases [yes]? no
Update /var/spool/fax/status/any.info.

        HylaFAX configuration parameters are:

        [1] Init script starts faxq:            yes
        [2] Init script starts hfaxd            yes
        [3] Start old protocol:                 no
        [4] Start paging protocol:              no
Are these ok [yes]?

Modem support functions written to /var/spool/fax/etc/setup.modem.
Configuration parameters written to /var/spool/fax/etc/setup.cache.

No scheduler config file exists, creating one from scratch.
Country code [1]? 7
Area code []? 496
Long distance dialing prefix [1]? 8
International dialing prefix [011]?
Dial string rules file (relative to /var/spool/fax) ["etc/dialrules"]?
Tracing during normal server operation [1]?
Default tracing during send and receive sessions [0xffffffff]?
Continuation cover page (relative to /var/spool/fax) []?
Timeout when converting PostScript documents (secs) [180]?
Maximum number of concurrent jobs to a destination [1]?
Define a group of modems []?
Time of day restrictions for outbound jobs ["Any"]?
Pathname of destination controls file (relative to /var/spool/fax) []?
Timeout before purging a stale UUCP lock file (secs) [30]?
Max number of pages to permit in an outbound job [0xffffffff]?
Syslog facility name for ServerTracing messages [daemon]?

The non-default scheduler parameters are:

CountryCode:            7
AreaCode:               496
LongDistancePrefix:     8

Are these ok [yes]?
Creating new configuration file /var/spool/fax/etc/config...

Restarting HylaFAX server processes.
Should I restart the HylaFAX server processes [yes]?

/etc/init.d/hylafax start
 * Caching service dependencies ...                                                                                    [ ok ]
 * Check hylafax server configuration... ...
 * Use spool directory /var/spool/fax
 * Starting HylaFAX server daemons ...
 * Starting /usr/sbin/faxq ...
 * Starting /usr/sbin/hfaxd with args -l 127.0.0.1 -q /var/spool/fax -i hylafax -d                                     [ ok ]

You do not appear to have any modems configured for use.  Modems are
configured for use with HylaFAX with the faxaddmodem(8C) command.
Do you want to run faxaddmodem to configure a modem [yes]?
Serial port that modem is connected to []? ttyIAX

Ok, time to setup a configuration file for the modem.  The manual
page config(5F) may be useful during this process.  Also be aware
that at any time you can safely interrupt this procedure.

Reading scheduler config file /var/spool/fax/etc/config.

No existing configuration, let's do this from scratch.

Country code [1]? 7
Area code [415]? 496
Phone number of fax modem [+1.999.555.1212]? +7.496.549.9057
Local identification string (for TSI/CIG) ["NothingSetup"]? CSIT
Long distance dialing prefix [1]? 8
International dialing prefix [011]?
Dial string rules file (relative to /var/spool/fax) [etc/dialrules]?
Tracing during normal server operation [1]?
Tracing during send and receive sessions [11]?
Protection mode for received facsimile [0600]?
Protection mode for session logs [0600]?
Protection mode for ttyIAX [0600]?
Rings to wait before answering [1]?
Modem speaker volume [off]?
Command line arguments to getty program ["-h %l dx_%s"]?
Pathname of TSI access control list file (relative to /var/spool/fax) [""]?
Pathname of Caller-ID access control list file (relative to /var/spool/fax) [""]?
Tag line font file (relative to /var/spool/fax) [etc/lutRS18.pcf]?
Tag line format string ["From %%l|%c|Page %%P of %%T"]?
Time before purging a stale UUCP lock file (secs) [30]?
Hold UUCP lockfile during inbound data calls [Yes]?
Hold UUCP lockfile during inbound voice calls [Yes]?
Percent good lines to accept during copy quality checking [95]?
Max consecutive bad lines to accept during copy quality checking [5]?
Max number of pages to accept in a received facsimile [25]?
Syslog facility name for ServerTracing messages [daemon]?
Set UID to 0 to manipulate CLOCAL [""]?
Use available priority job scheduling mechanism [""]?

The non-default server configuration parameters are:

CountryCode:            7
AreaCode:               496
FAXNumber:              +7.496.549.9057
LongDistancePrefix:     8
InternationalPrefix:    011
DialStringRules:        etc/dialrules
SessionTracing:         11
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        CSIT
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l|%c|Page %%P of %%T"
MaxRecvPages:           25

Are these ok [yes]?

Now we are going to probe the tty port to figure out the type
of modem that is attached.  This takes a few seconds, so be patient.
Note that if you do not have the modem cabled to the port, or the
modem is turned off, this may hang (just go and cable up the modem
or turn it on, or whatever).

Probing for best speed to talk to modem: 38400 OK.

About fax classes:

The difference between fax classes has to do with how HylaFAX interacts
with the modem and the fax protocol features that are used when sending
or receiving faxes.  One class isn't inherently better than another;
however, one probably will suit a user's needs better than others.

Class 1 relies on HylaFAX to perform the bulk of the fax protocol.
Class 2 relies on the modem to perform the bulk of the fax protocol.
Class 2.0 is similar to Class 2 but may include more features.
Class 1.0 is similar to Class 1 but may add V.34-fax capability.
Class 2.1 is similar to Class 2.0 but adds V.34-fax capability.

HylaFAX generally will have more features when using Class 1/1.0 than
when using most modems' Class 2 or Class 2.0 implementations.  Generally
any problems encountered in Class 1/1.0 can be resolved by modifications
to HylaFAX, but usually any problems encountered in Class 2/2.0/2.1 will
require the modem manufacturer to resolve it.

Use Class 1 unless you have a good reason not to.

This modem looks to have support for Class 1 and 1.0.
How should it be configured [1]?

Hmm, this looks like a Class 1 modem.
Product code (ATI0) is "spandsp".
Other information (ATI3) is "www.soft-switch.org".
DTE-DCE flow control scheme [default]?
Modem manufacturer is "spandsp".
Modem model is "IAXmodem".

Using prototype configuration file iaxmodem...

The modem configuration parameters are:

ModemResetCmds:         "ATH1\nAT+VCID=1"

Are these ok [yes]?

Creating new configuration file /var/spool/fax/etc/config.ttyIAX...
Done setting up the modem configuration.

Checking /var/spool/fax/etc/config for consistency...
...some parameters are different.

The non-default scheduler parameters are:

CountryCode:            7
AreaCode:               496
LongDistancePrefix:     8
InternationalPrefix:    011
DialStringRules:        etc/dialrules

Are these ok [yes]?

Creating new configuration file /var/spool/fax/etc/config...
...saving current file as /var/spool/fax/etc/config.sav.

Don't forget to run faxmodem(8C) (if you have a send-only environment)
or configure init to run faxgetty on ttyIAX.
Do you want to run faxaddmodem to configure another modem [yes]? no

Looks like you have some faxgetty processes running (PIDs are):

    1566

It is usually a good idea to restart these processes after running
faxsetup; especially if have just installed new software.  If these
processes are being started by init(8C) then sending each of them a
QUIT message with the faxquit command should cause them to be restarted.
Is it ok to send a QUIT command to each process [yes]?
/usr/sbin/faxquit ttyIAX

Done verifying system setup.

Несколько оставшихся команд для конфигурации запуска hylafax при старте системы и отсылки принимаемых факсов на е-мейл:

rc-update add hylafax default && /etc/init.d/hylafax start
cat > /var/spool/fax/etc/FaxDispatch <<end-of-text
SENDTO=csit.fax@spnet.ru
FILETYPE=pdf
NOTIFY_FAXMASTER=never
end-of-text

Теперь устанавливаем версию флэш панели администратора, которая поддерживает * 1.6:

cd /var/www/localhost/htdocs/panel
wget http://www.asternic.org/op_server.pl
mv op_server.pl op_server.pl.save ; mv op_server.pl.1 op_server.pl ; chown asterisk op_server.pl ; chmod 750 op_server.pl ; amportal stop ; amportal kill ; amportal start

Руссифицируем наш *:

cd /var/lib/asterisk/sounds/
wget http://klyaznik.ru/wp-content/uploads/2009/05/sounds-ru-16_2515.tgz
tar zxvf sounds-ru-16_2515.tgz

Все звуковые файлы записаны с помощью синтезатора голоса Alyona компании Acapela в программе Balabolka. Большой их минус в произношении – иногда синтезатор голоса неправильно расставляет ударения, комкает слова и т. д. Если у кого-нибудь есть время и желание исправить это – пишите, я подскажу как это сделать и выложу исправленные файлы. Плюс же руссификации с помощью синтезатора в том, что всегда можно дописать необходимые фразы аналогичным голосом, даже используя демонстрацию на сайте Acapela и какую-нибудь программу аудиозахвата.

Заметил некоторую странность: каналы типа Local плюют на настройки локализации и проигрывают файлы с языком по умолчанию, который обычно ‘en’.  Я добавил в соответствующие макросы FreePBX жесткую установку языка в ru:

cat >> /etc/asterisk/extensions_override_freepbx.conf <<end-of-text
[macro-outisbusy]
exten => s,1,Set(CHANNEL(language)=ru)
exten => s,n,Playback(all-circuits-busy-now,noanswer)
exten => s,n,Playback(pls-try-call-later,noanswer)
exten => s,n,Macro(hangupcall)

[macro-exten-vm]
exten => s,1,Macro(user-callerid)

exten => s,n,Set(RingGroupMethod=none)
exten => s,n,Set(VMBOX=${ARG1})
exten => s,n,Set(EXTTOCALL=${ARG2})
exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})})
exten => s,n,Set(CFBEXT=${DB(CFB/${EXTTOCALL})})
exten => s,n,Set(RT=${IF($[$["${VMBOX}"!="novm"] | $["foo${CFUEXT}"!="foo"]]?${RINGTIMER}:"")})
exten => s,n,Macro(record-enable,${EXTTOCALL},IN)
exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL})
exten => s,n,GotoIf($[ $["${VMBOX}" != "novm"] & $["${SCREEN}" != ""] & $["${DIALSTATUS}" = "NOANSWER"] ]?exit,return)
exten => s,n,Set(SV_DIALSTATUS=${DIALSTATUS})
exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="NOANSWER"] & $["${CFUEXT}"!=""] & $["${SCREEN}" = ""]]?docfu,1) ; check for CFUin use on no answer
exten => s,n,GosubIf($[$["${SV_DIALSTATUS}"="BUSY"] & $["${CFBEXT}"!=""]]?docfb,1) ; check for CFB in use on busy
exten => s,n,Set(DIALSTATUS=${SV_DIALSTATUS})
exten => s,n,NoOp(Voicemail is '${VMBOX}')
exten => s,n,GotoIf($["${VMBOX}" = "novm"]?s-${DIALSTATUS},1) ; no voicemail in use for this extension
exten => s,n,NoOp(Sending to Voicemail box ${EXTTOCALL})
exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS},${IVR_RETVM})

; Try the Call Forward on No Answer / Unavailable number
exten => docfu,1,Set(RTCFU=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
exten => docfu,n,Dial(Local/${CFUEXT}@from-internal/n,${RTCFU},${DIAL_OPTIONS})
exten => docfu,n,Return

; Try the Call Forward on Busy number
exten => docfb,1,Set(RTCFB=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")})
exten => docfb,n,Dial(Local/${CFBEXT}@from-internal/n,${RTCFB},${DIAL_OPTIONS})
exten => docfb,n,Return

; Extensions with no Voicemail box reporting BUSY come here
exten => s-BUSY,1,NoOp(Extension is reporting BUSY and not passing to Voicemail)
exten => s-BUSY,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?exit,1)
exten => s-BUSY,n,Playtones(busy)
exten => s-BUSY,n,Busy(20)

; Anything but BUSY comes here
exten => _s-.,1,Noop(IVR_RETVM: ${IVR_RETVM} IVR_CONTEXT: ${IVR_CONTEXT})
exten => _s-.,n,GotoIf($["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]?exit,1)
exten => _s-.,n,Playtones(congestion)
exten => _s-.,n,Congestion(10)

; Short burst of tones then return
exten => exit,1,Set(CHANNEL(language)=ru)
exten => exit,n,Playback(beep&line-busy-transfer-menu&silence/1)
exten => exit,n(return),MacroExit()
end-of-text

Вот вроде бы и все.

Комментарии запрещены.