FreePBX | Register | Issues | Wiki | Portal | Support

Howto install Hylafax and IAX-Modem on AsteriskNow-CentOS / FreePBX


(Comfine GmbH) #1

Hey there,

i think there are not much easy to use howtos online…so i just reused my one and it worked perfect - so i want to share my documentation to help you…

yum install rpm sharutils
mkdir /temp
cd /temp
wget http://yum.trixbox.org/centos/5/RPMS/hylafax-4.4.4-1rhel5.i386.rpm
wget ftp://ftp.hylafax.org/binary/linux/redhat/6.0.6/hylafax-server-6.0.6-1rhel6.x86_64.rpm
wget ftp://ftp.hylafax.org/binary/linux/redhat/6.0.6/hylafax-client-6.0.6-1rhel6.x86_64.rpm
rpm -i hylafax-server-6.0.6-1rhel6.x86_64.rpm hylafax-client-6.0.6-1rhel6.x86_64.rpm
/usr/sbin/faxsetup
Press enter for all, expect following:
Country code [1]? <- enter value for your country…
Area code []? <- enter value for your country WIHTOUT leading numbers
Long distance dialing prefix [1]? < enter value for your country…
International dialing prefix [011]? enter value for your country…
if faxaddmodem is called, insert NO or press CTR+C

wget http://downloads.sourceforge.net/project/iaxmodem/iaxmodem/iaxmodem-1.2.0/iaxmodem-1.2.0.tar.gz
gunzip iaxmodem-1.2.0.tar.gz
tar xfv iaxmodem-1.2.0.tar
cd iaxmodem-1.2.0
./build static
cp iaxmodem /usr/local/sbin
mkdir /etc/iaxmodem
vi /etc/iaxmodem/ttyIAX0
insert the following lines and save:
device /dev/ttyIAX0
owner uucp:uucp
mode 666
port 4570
refresh 50
server 127.0.0.1
peername extension_number_that_you_create_later_in_freepbx
secret password_you_will_enter_later_in_freepbx
codec alaw

vi config.ttyIAX
change the following lines to your need:
CountryCode: your countrycode!
AreaCode: your areacode WITHOUT leading numbers
FAXNumber: type in complete number with international predial
LongDistancePrefix: as in your country…
InternationalPrefix: as in your country…
RecvFileMode: 0777
LocalIdentifier: your_complete_fax_identifier (is written on each fax you send…)

cp config.ttyIAX /var/spool/hylafax/etc/config.ttyIAX0

vi /etc/init/iaxmodem.conf
insert and save following:
start on stopped rc RUNLEVEL=123
stop on runlevel !123
respawn
exec /usr/local/sbin/iaxmodem ttyIAX0

vi /etc/init/faxgetty.conf
insert following and save:
start on stopped rc RUNLEVEL=123
stop on runlevel !123
respawn
exec /usr/sbin/faxgetty ttyIAX0

vi /etc/rc.local
insert following and save:
start iaxmodem
start faxgetty

vi /var/spool/hylafax/etc/hosts.hfaxd
add and save:
192.168.xxx.* <— while X is your local ip range…

vi /var/spool/hylafax/etc/FaxDispatch
change and save
SENDTO=your_email_receiver_if_you_want_get_fax_per_mail

vi /var/spool/hylafax/bin/pdf2fax.gs
change
vres=98
to
vres=196
and save

in freepbx
check that Module “Asterisk IAX Settings” is installed
Open it and insert under Other IAX settings
calltokenoptional = 0.0.0.0/0.0.0.0
maxcallnumbers = 16382

create a new extension IAX2, use the extension-number you specified in the ttyIAX0-File, and the secret. set the otpion requirecalltoken to NO.

reboot the system and you are done!

have fun!


(Xristos Zel) #2

Hello my frient, do you have a how-to for the Winprint Hylafax Client to send faxes from computer?


#3

@comfine Thank you for your documentation.

I did the Setup on the Official Sangoma SNG7 Distro today:

here is the documentation:

My steps to get Hylafax working on SNG7

yum install hylafax+ hylafax+-client -y

yum install libtiff-devel

wget https://sourceforge.net/projects/iaxmodem/files/iaxmodem/iaxmodem-1.3.0.tar.gz

tar xfpz iaxmodem-1.3.0.tar.gz

cd iaxmodem-1.3.0

./build static
cp iaxmodem /usr/local/sbin
mkdir /etc/iaxmodem

nano /etc/iaxmodem/ttyIAX0

insert the following lines and save:

device /dev/ttyIAX0
owner uucp:uucp
mode 666
port 4570
refresh 50
server 127.0.0.1
peername YOUREXTENSIONNUMBER
secret YOURPASSWORDFROMIAX2EXTENSION
codec alaw

/usr/sbin/faxsetup

Press enter for all, expect following:
Country code [1]? <- enter value for your country…
Area code []? <- enter value for your country WIHTOUT leading numbers
Long distance dialing prefix [1]? < enter value for your country…
International dialing prefix [011]? enter value for your country…

if faxaddmodem is called, insert NO or press CTR+C

nano config.ttyIAX

change the following lines to your need:

CountryCode: your countrycode!
AreaCode: your areacode WITHOUT leading numbers
FAXNumber: type in complete number with international predial
LongDistancePrefix: as in your country…
InternationalPrefix: as in your country…
RecvFileMode: 0777
LocalIdentifier: your_complete_fax_identifier (is written on each fax you send…)

cp config.ttyIAX /var/spool/hylafax/etc/config.ttyIAX0

nano /etc/systemd/system/iaxmodem.service

insert and save following:

[Unit]
Description = IAXmodem for /dev/ttyIAX0
ConditionPathExists = /etc/iaxmodem/ttyIAX0
Requires = freepbx.service
After = freepbx.service

[Service]
Type = simple
Restart=always
RestartSec=30
ExecStart = /usr/local/sbin/iaxmodem ttyIAX0

[Install]
WantedBy=multi-user.target

Enable the service to make it autorun:
systemctl enable iaxmodem

nano /etc/systemd/system/faxgetty.service

insert and save following:

[Unit]
Description = Faxgetty for /dev/ttyIAX0
Requires = freepbx.service
After = freepbx.service

[Service]
Type = simple
Restart=always
RestartSec=30
ExecStart = /usr/sbin/faxgetty ttyIAX0

[Install]
WantedBy=multi-user.target

Enable the service to make it autorun:
systemctl enable faxgetty

nano /etc/systemd/system/hfaxd.service

insert and save following:

[Unit]
Description = Hylafax hfaxd
#ConditionPathExists = /etc/iaxmodem/ttyIAX
Requires = freepbx.service
After = freepbx.service

[Service]
#User=root
#Group=root
Type = forking
ExecStart = /usr/sbin/hfaxd -i hylafax

[Install]
WantedBy=multi-user.target

Enable the service to make it autorun:
systemctl enable hfaxd

nano /etc/systemd/system/faxq.service

insert and save following:

[Unit]
Description = faxq
Requires = freepbx.service
After = freepbx.service
[Service]
Type = forking
ExecStart = /usr/sbin/faxq

[Install]
WantedBy=multi-user.target

Enable the service to make it autorun:
systemctl enable faxq

nano /var/spool/hylafax/etc/hosts.hfaxd
Enter your IP Adresseses which should have access to the Server
IP ADRESS

nano /var/spool/hylafax/bin/pdf2fax.gs
change
vres=98
to
vres=196
and save

in freepbx
check that Module “Asterisk IAX Settings” is installed
Open it and insert under Other IAX settings
calltokenoptional = 0.0.0.0/0.0.0.0
maxcallnumbers = 16382

create a new extension IAX2, use the extension-number you specified in the ttyIAX0-File, and the secret. set the option requirecalltoken to NO.

reboot the system and you are done!


(Comfine GmbH) #4

i just had this autostart problem aswell some days ago. its related to changings in the most linux distros from initd to systemd. it took me two hours or something, but finally it worked:

i created 4 files:

create files in /etc/systemd/system and link them to /etc/systemd/system/multi-user.target.wants

/etc/systemd/system/hfaxd.service
[Unit]
Description = Hylafax hfaxd
#ConditionPathExists = /etc/iaxmodem/ttyIAX
#Requires = asterisk.service
#After = asterisk.service

[Service]
#User=root
#Group=root
Type = forking
ExecStart = /usr/sbin/hfaxd -i hylafax

[Install]
WantedBy=multi-user.target

/etc/systemd/system/faxq.service
[Unit]
Description = faxq
[Service]
Type = forking
ExecStart = /usr/sbin/faxq

[Install]
WantedBy=multi-user.target

/etc/systemd/system/faxgetty.service
[Unit]
Description = faxgetty
#ConditionPathExists = /etc/faxgetty/ttyIAX0
#Requires = asterisk.service
#After = asterisk.service

[Service]
Type = simple
Restart=always
RestartSec=30
ExecStart = /usr/sbin/faxgetty ttyIAX0

[Install]
WantedBy=multi-user.target

/etc/systemd/system/iaxmodem.service
[Unit]
Description = IAXmodem for /dev/ttyIAX
#ConditionPathExists = /etc/iaxmodem/ttyIAX
#Requires = asterisk.service
#After = asterisk.service

[Service]
Type = simple
Restart=always
RestartSec=30
ExecStart = /usr/local/sbin/iaxmodem ttyIAX0

[Install]
WantedBy=multi-user.target

reboot - services shoud run as expected.


(Comfine GmbH) #5

hahah - now i see that you worked out that same changes :smiley:
thanks for sharing!

maybe its helpful anyway, cause i created files for hylafax aswell because it was not running on boot on my system after upgrading to FreePBX14


#6

Thank you very much,

the services hfaxd and faxq where on state “working on” before :smiley:

Now everything works with the SNG7 Distro directly and i can put the old Elastix machine away.

I updated my documentation and anyone can use it at own risk with de FreePBX Distro.

Regards,

Matthias


#7

@comfine

Did you ever install this on Sangomas SNG Distro?

After installing the Hylafax Software Fail2ban and Responsive Firewall do not autostart anymore on boot!

But i cant find the error now.


(Comfine GmbH) #8

i upgraded the FreePBX Distro to the v14 - and if i understand that “changed” the distro to Sangoma SNG - but i never used fail2ban and resp. firewall. - so no idea if that is working or not.


#9

Oh okay so i need to ask someone else or Sangoma :smiley: but i think they will not answer because they have the FAX Pro module.

I already tested a few things.

After i disabled the 4 services the Firewall starts on boot.
If i enable at least one of the 4 services then the problems starts. Fail2ban and Firewall stay stopped.
@xrobau i think you are the Firewall and Distro guru. :slight_smile: What can be the the problem, when i enable another systemctl service so that Fail2ban and Firewall stay stopped on boot?


(Comfine GmbH) #10

@mitterhuemer
have you checked the logfiles already? check /var/log/messages if you see why it does not start. there are som commands for checking systemd-services. check the systemctl commands, i think theres something to check status with details for a service aswell. maybe that helps.


#11

I already checked the messages file. Also the freepbx.log and asterisk logfiles. The strange thing is if i write fwconsole firewall start after boot then everything works without any error but i dont want to have any workaround solution


(Comfine GmbH) #12

sounds like there is a problem with the order of the services - maybe you should just try to insert commands to start the other services later or earlier! (there was a line that can handle that in the systemd-service-config-files)


#13

I think the Problem is solved.

Systemd UNIT Settings are wrong:

Requires = asterisk.service
After = asterisk.service

This starts asterisk before fwconsole can do it.
Fwconsole says “Asterisk is already started” and so it stops starting services.

I changed all entries to:

Requires = freepbx.service
After = freepbx.service

This started all services including Fail2ban and Asterisk.
I updated the documentation.


(Comfine GmbH) #14

just install YAJHFC and enter the IP of your hylafax-server - should be work without any problems.


(Greg) #15

Great howto!

I’d like to expand just a little on FaxDispatch

If you’re like me, you have multiple departments. I have 8 iaxmodems running on my box, with fax routing based on the inbound number.

My FaxDispatch looks similar to this (the number have been changed to protect… well… me. lol)

FILETYPE=pdf;
SENDTO=FaxMaster;
NOTIFY_FAXMASTER=errors;
case $CALLID4 in
  *3022) SENDTO=sales@mydomain.com;;
  *3033) SENDTO=service@mydomain.com;;
  *3034) SENDTO=hr@mydomain.com;;
  *) SENDTO=otherfaxbox@mydomain.com;;
esac

Notice the last one… that’s the “I got a fax, but I didn’t get a match, so who do I send those to?” line.

Hopefully this helps someone else out who has multiple departments with faxes!


(Greg) #16

Oh, I also keep a little shell script in my home folder to restart the faxes and services, especially useful if something has gone wonky, services didn’t start, or if there was a configuration change that I made and needed to restart everything.

!/bin/bash
service hylafax+ stop
killall iaxmodem
stop ttyIAX0
stop ttyIAX1
stop ttyIAX2
stop ttyIAX3
stop ttyIAX4
stop ttyIAX5
stop ttyIAX6
stop ttyIAX7

asterisk -rx "module unload chan_iax2.so"
sleep 10

asterisk -rx "module load chan_iax2.so"
start ttyIAX0
start ttyIAX1
start ttyIAX2
start ttyIAX3
start ttyIAX4
start ttyIAX5
start ttyIAX6
start ttyIAX7

iaxmodem

service hylafax+ start

To run it, just ./restartmodems.sh in your home directory.

As you can see, it restarts Hylafax, iaxmodems, and even forces the IAX module to reload in Asterisk.