IAXModem with Sail and HylaFax

From SME Server
Revision as of 22:25, 15 January 2010 by Timn (talk | contribs)
Jump to navigationJump to search
Incomplete.png Incomplete:
This article or section needs to be expanded. Please help to fill the gaps or discuss the issue on the talk page


Introduction

This Howto is aimed at the installation of IAXModem in conjunction with SAIL/asterisk and Hylafax in order to provide a fax over VOIP solution. It is based on information from various forum posts including:

http://forums.contribs.org/index.php/topic,39258.msg179460.html

http://forums.contribs.org/index.php/topic,41256.msg219493.html


Important.png Note:
This has only been tested with Asterisk 1.4.25.1-78, Sail 2.4.1-2 and the Hylafax Contrib from Dungog smeserver-hylafax-0.9.6 with hylafax-4.4.4-1

No other asterisk implementations have been used or tested. It is assumed that you have a working Sail/asterisk installation


Sail and Asterisk Setup

General

In Global Settings

  • Make sure that 'Late Termination' is set to No.
  • Make sure that the 'Autosense FAX Extension' is set to a number you want to use for the Fax. You will need this number later.
  • The 'Fax Delay' setting defaults to 2 seconds. You may need to adjust this later to make sure faxes get detected before asterisk attempts to terminate somewhere other than the FAX.

For each of the Trunks under Trunklines that you want to be able to detect incoming Faxes on

  • Make sure that the 'Fax' detection tick box is ticked

Fax Extension

Create a new Extension with the same number as set in the 'Autosense FAX Extension' as above - or vice versa. The 'Device' should be IAXModem.

Important.png Note:
We will assume an extension number of 2000, a password (secret) of asterisk and a Display Name of FaxModem


Once created check the stanza generally conforms to the following and change as necessary:

[2000]
type=friend
username=FaxModem
secret=asterisk
host=dynamic
qualify=3000
context=internal
callerid="Faxmodem" <2000>
disallow=all
allow=slin

IAXModem

Installation

Important.png Note:
Sail installs /etc/rc.d/rc7.d/S93iaxmodem but does not install /etc/rc.d/init.d/iaxmodem


Download the iaxmodem rpm from Aelintra and install

wget http://sarkpbx.com/sail/iaxmodem/iaxmodem-1.0.0-1.noarch.rpm
yum localinstall iaxmodem-1.0.0-1.noarch.rpm
Important.png Note:
Current version of iaxmodem is 1.2 but there doesn't appear to a Centos 4 package for it anywhere


Warning.png Warning:
The rpm from Aelintra does not install /etc/rc.d/init.d/iaxmodem so you will need to create one. A copy of the current version 1.2 code is reproduced at the end of this Howto. You may need to set the permissions and ownership
chmod 766 iaxmodem
chown root:root iaxmodem


Configuration

Check and edit /etc/iaxmodem/ttyIAX0 as necessary:

device          /dev/ttyIAX
owner           uucp:uucp
mode            660
port            4570
refresh         60
server          127.0.0.1
peername        2000
secret          asterisk
cidname         YourCompany
cidnumber       0123456789
codec           slinear

Check and Run

Check the modem registers with Sail and Asterisk

/usr/local/sbin/iaxmodem ttyIAX

should give an output similar to

Modem started
Setting device = '/dev/ttyIAX'
Setting owner = 'uucp:uucp'
Setting mode = '660'
Setting port = 4570
Setting refresh = 60
Setting server = '127.0.0.1'
Setting peername = '2000'
Setting secret = 'asterisk'
Setting cidname = 'YourCompany'
Setting cidnumber = '0123456789'
Setting codec = slinear
Opened pty, slave device: /dev/pts/0
Created /dev/ttyIAX symbolic link
Registration completed successfully.

and in an asterisk CLI

--Registered IAX2 '2000' (AUTHENTICATED) at 127.0.0.1:4570

Now

db configuration set iaxmodem service status enabled
/etc/rc.d/rc7.d/S93iaxmodem start

Hylafax

Install the smeserver-hylafax contrib.

iaxmodem Startup Script

The following is the code for the /etc/rc.d/init.d/iaxmodem script from the current iaxmodem-1.2.0.tar.gz source.

#!/bin/sh
# Startup script for iaxmodem
#
# chkconfig: 2345 95 05
# description: IAXModem for asterisk <-> Hylafax gateway 

# Source function library.
. /etc/rc.d/init.d/functions

[ -f /usr/local/sbin/iaxmodem ] || exit 0

prog="IAXmodem"

start() {
    echo -n $"Starting $prog: "
    daemon /usr/local/sbin/iaxmodem
    RETVAL=$?
    echo
    return $RETVAL
}

stop() {
    if test "x`pidof iaxmodem`" != x; then
        echo -n $"Stopping $prog: "
        killproc iaxmodem
        echo
    fi
    RETVAL=$?
    return $RETVAL
}

reload() {
   if test "x`pidof iaxmodem`" != x; then
      echo $"Reloading $prog"
      kill -HUP `head -1 /var/run/iaxmodem.pid`
   fi
}

case "$1" in
        start)
            start
            ;;
        stop)
            stop
            ;;
        status)
            status iaxmodem
            ;;
        reload)
            reload
            ;;
        restart)
            stop
            start
            ;;
        condrestart)
            if test "x`pidof iaxmodem`" != x; then
                stop
                start
            fi
            ;;

        *)
            echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
            exit 1

esac

exit $RETVAL