FaxServer using Asterisk: Difference between revisions
(More draft notes about asterisk as faxserver) |
(→Configure dialplan: Using variable for setting path to various files. Adding some debug output) |
||
Line 109: | Line 109: | ||
_X. {{=}}> { | _X. {{=}}> { | ||
Set(FAXDATE{{=}}${STRFTIME(,,%Y%m%d%H%M%S)}); | Set(FAXDATE{{=}}${STRFTIME(,,%Y%m%d%H%M%S)}); | ||
Set(FAXFILE{{=}}/ | Set(FAXPATH{{=}}/etc/asterisk/spool); | ||
Set(FAXFILE{{=}}${FAXPATH}/fax_incoming_${EXTEN}_${FAXDATE}.tif); | |||
Answer(); | Answer(); | ||
System(/bin/mkdir -p ${FAXPATH}); | |||
Wait(1); | Wait(1); | ||
ReceiveFax(${FAXFILE},f); | ReceiveFax(${FAXFILE},f); | ||
Verbose(3,- Fax receipt completed with status: ${FAXSTATUS}); | Verbose(3,- Fax receipt completed with status: ${FAXSTATUS}); | ||
if ("${FAXSTATUS}" {{=}} "FAILED") { | if ("${FAXSTATUS}" {{=}} "FAILED") { | ||
Set(DEBUGINFO | Set(DEBUGINFO{{=}}FAXSTATUS: ${FAXSTATUS}\nFAXERROR: ${FAXERROR}\nLOCALSTATIONID: ${LOCALSTATIONID}\nLOCALHEADERINFO: ${LOCALHEADERINFO}\nREMOTESTATIONID: ${REMOTESTATIONID}\nFAXPAGES: ${FAXPAGES}\nFAXBITRATE: ${FAXBITRATE}\nFAXRESOLUTION: ${FAXRESOLUTION}); | ||
Verbose(3,- Trying to send a email reporting the failure}); | Verbose(3,- Trying to send a email reporting the failure}); | ||
System(echo "${DEBUGINFO}" {{!}} /usr/bin/email -s "Incoming fax for ${EXTEN} failed" grp-support); | System(/bin/echo "${DEBUGINFO}" {{!}} /usr/bin/email -s "Incoming fax for ${EXTEN} failed" grp-support); | ||
System( | System(/bin/mkdir -p ${FAXPATH}/fax-failed); | ||
System( | System(/bin/mv ${FAXFILE} ${FAXPATH}/fax-failed/); | ||
System(/bin/echo '${FAXDATE} - Failed receiving fax originated for ${EXTEN}\n${DEBUGINFO}\n\n' >> ${FAXPATH}/error.log); | |||
} else { | } else { | ||
Verbose(3,- Trying to send a email containing the fax | Verbose(3,- Trying to send a email containing the fax); | ||
System(/usr/bin/email -s "Incoming fax for ${EXTEN} failed" -b -a ${FAXFILE} grp-${EXTEN}); | System(/usr/bin/email -s "Incoming fax for ${EXTEN} failed" -b -a ${FAXFILE} grp-${EXTEN}); | ||
System( | System(/bin/mkdir -p ${FAXPATH}/fax-processed); | ||
System( | System(/bin/mv ${FAXFILE} ${FAXPATH}/fax-processed/); | ||
System(/bin/echo '${FAXDATE} - Successfuly received fax originated for ${EXTEN} (${FAXFILE})' >> ${FAXPATH}/success.log); | |||
}; | }; | ||
}; | }; |
Revision as of 16:11, 2 July 2013
This material is work-in-progress ... This is a experimental page to see if this could replace a more complex setup using Asterisk+IAXmodem+hylafax |
This document aims to create a as simple as possible to setup fax server to send and receive faxes using asterisk and asterisk-fax.
Installation
This wiki-doc is based on Alpine Linux 2.6 (but might also work on version 2.1.3 or higher)
Start by setting up a Alpine Linux base system (you will most likely want to run setup-alpine
to setup the most basic settings)
Firewall
You might want to setup a firewall to protect your system. We will not address this task in this document. Some firewall alternatives in Alpine Linux are
- AWall
- Shorewall
- iptables
Configure email
Install required packages
We will use the package email to send the faxes by email to various recipients. Lets start by installing the package
apk add email
General configuration
- Edit the appropriate file
vi /etc/email/email.conf
- Change the variables
SMTP_SERVER
,SMTP_PORT
,MY_NAME
,MY_EMAIL
,ADDRESS_BOOK
- Comment out the variable
SIGNATURE_FILE
Address book
- Edit the appropriate file (In this example we assume you did not change the value of
ADDRESS_BOOK
variable).
vi /etc/email/email.address.template
- Define some email addresses that suits your needs.
The upcoming asterisk config assumes that you have some predefined records in this address book. Example:
Contents of /etc/email/email.address.template
Test functionality
When you done your email configuration you can test this by running commands like this:
email -s "testmail" -b jeff
Configure Asterisk
There are multiple ways to configure Asterisk. This document only describes a very basic setup which you might want to modify based on your needs. But by following this document, you should have a fully functional fax-server using only asterisk and asterisk-fax.
Install required packages
At this stage your Alpine Linux only holds some basic packages for base functionallity. We will need to install some extra packages in order to get the fax functionallity.
apk add asterisk asterisk-fax
General setup
Set some general settings
- Edit the appropriate file
vi /etc/asterisk/asterisk.conf
- Copy this content to the file
Contents of /etc/asterisk/asterisk.conf
Load appropreate modules
Asterisk needs some modules to be able to handle fax.
- Edit the appropriate file
vi /etc/asterisk/modules.conf
- Copy this content to the file
Contents of /etc/asterisk/modules.conf
Enable SIP
- Edit the appropriate file
vi /etc/asterisk/sip.conf
- Copy this content to the file
Contents of /etc/asterisk/sip.conf
Configure dialplan
- Edit the appropriate file
vi /etc/asterisk/extensions.ael
- Copy this content to the file
Contents of /etc/asterisk/extensions.ael
Permissions
For asterisk to be able to read the new config files, we need to set the correct permissions to the files
chown -R asterisk:asterisk /etc/asterisk
Start things up
Now its time to start up the services
/etc/init.d/asterisk start
Configure asterisk to autostart at next reboot
rc-update add asterisk