<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LAMP with ·dotmanila &#187; fax</title>
	<atom:link href="http://dotmanila.com/blog/tag/fax/feed/" rel="self" type="application/rss+xml" />
	<link>http://dotmanila.com/blog</link>
	<description>Linux, Apache, PHP, MySQL Musings</description>
	<lastBuildDate>Sun, 01 Apr 2012 17:24:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Automated Document Collection via Fax using HylaFax</title>
		<link>http://dotmanila.com/blog/2008/05/automated-document-collection-via-fax-using-hylafax/</link>
		<comments>http://dotmanila.com/blog/2008/05/automated-document-collection-via-fax-using-hylafax/#comments</comments>
		<pubDate>Wed, 28 May 2008 10:58:07 +0000</pubDate>
		<dc:creator>jervin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[document collection]]></category>
		<category><![CDATA[fax]]></category>
		<category><![CDATA[fax daemon]]></category>
		<category><![CDATA[hylafax]]></category>

		<guid isPermaLink="false">http://dotmanila.com/blog/?p=14</guid>
		<description><![CDATA[I. Our OS of choice is CentOS (latest release 5.1) since a HylaFAX rpm is widely available. Assuming we already have a working OS with its network properly configured to reach outside world. II. Secondly we need to install our modem of choice, in this case a Conexant based data/fax modem. To support the fax [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I.</strong> Our OS of choice is CentOS (latest release 5.1) since a HylaFAX rpm is widely available. Assuming we already have a working OS with its network properly configured to reach outside world.</p>
<p><strong>II.</strong> Secondly we need to install our modem of choice, in this case a Conexant based data/fax modem. To support the fax capability we need to use the paid version of the linuxant.org HSF softmodem driver. Their website (linuxant.org) provides and simple and easy way to install the driver as well as activating the purchased license.</p>
<p><strong>III.</strong> For more convenience we will create a middle user or utility user called ‘faxman’ using whatever password plus we also generate an rsa private key pair. Assuming an rsa key pair has been generated copy the private key to the $POOL/etc/ directory as ‘faxman_id_rsa’</p>
<p><code># cp /home/faxman/.ssh/id_rsa /var/spool/hylafax/etc/faxman_id_rsa<br />
# chown uucp.uucp /var/spool/hylafax/etc/faxman_id_rsa<br />
# chmod 0600 /var/spool/hylafax/etc/faxman_id_rsa </code></p>
<p>Another requirement is that the faxman user should be able to login to localhost using his private key so we do:</p>
<p><code>faxman@localhost ~$ cat .ssh/id_rsa.pub &gt; .ssh/authorized_keys2<br />
faxman@localhost ~$ chmod 0600 .ssh/*</code></p>
<p>So when you do:</p>
<p><code>faxman@localhost ~$ ssh localhost</code></p>
<p>faxman should login without a fuzz.</p>
<p><strong>IV.</strong> Our next step is HylaFax, searching over rpm.pbone.net we found a compatible rpm version 4.4.4 (http://rpm.pbone.net/index.php3/stat/4/idpl/6051053/com/hylafax-4.4.4-1rhel5.i386.rpm.html). Make sure before you install that you satisfied the dependencies (sharutils, gcc, ghostscript(optional)). Once the RPM has been installed faxsetup will automatically execute, accept all defaults except set the correct country code, area code and the phone number the modem will be attached to. Afterwards you will be prompted to configure your modem via faxaddmodem, same as faxsetup, accept defaults except country code, area code and phone number.</p>
<p><strong>V.</strong> Next we customize some scripts that comes with hylafax, first up $SPOOL/etc/FaxDispatch . Normally this file sends out email notification to the faxmaster (in our case faxman user) but we will add some values and procedures to scp in and call some external notication script.</p>
<p><code>## These values will determine to what server and directory the inbound facsimile is to be sent to.<br />
SSH_HOST=jhive.net;<br />
SSH_USER=&lt;user&gt;;<br />
SSH_PASS=&lt;pass&gt;;<br />
SSH_PREFIX=/home/hylafax/web;<br />
NOTIFY=http://www.jhive.net/hylafax/notify.php</code></p>
<p>Where:<br />
<strong>SSH_HOST</strong> : the remote host where we will scp our converted facsimiles to<br />
<strong>SSH_USER</strong> : the remote user<br />
<strong>SSH_PASS</strong> : optional, but keep here<br />
<strong>SSH_PREFIX</strong> : the remote directory to send the files to<br />
<strong>NOTIFY </strong> : an http based service that will be called with an attached querystring with the name of the scp’ed folder.</p>
<p>Another important requirement:<br />
Our ‘faxman’ user must be able to login to SSH_HOST as SSH_USER using only private key pair so you must set this up as well before attempting anything.</p>
<p>Our next script will be <code>$SPOOL/bin/faxrcvd</code> , this script handles whatever it is you want to do with RAW INBOUND (tiff) facsimiles. Open the faxrvcd script and replace the MailWithFAX procedure with this:</p>
<pre>MailWithFAX ()
{
    template="etc/templates/$TEMPLATE/faxrcvd-$1.txt"
    files_1=$FILE;
    filetype_1=TIFF;
    nfiles=1;
    for ft in $FILETYPE
    do
        ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgs $ft`
    done
    eval CreateMailMessage $template $ATTACH_ARGS \
        2&gt;$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi "$SENDTO"
    SSHDispatch
}

SSHDispatch ()
{
    IPAY_DATE=`date '+%Y%m%d%H%M%S'`
    if [ -d $TMPDIR ]
    then
        /bin/chmod -R 0777 $TMPDIR
        /usr/bin/ssh -i etc/faxman_id_rsa faxman@localhost "/usr/bin/scp -p -r $TMPDIR $SSH_USER@$SSH_HOST:$SSH_PREFI
X/$IPAY_DATE" 1&gt;&gt;log/scp.log 2&gt;&gt;log/scp.log
        export LYNX_TEMP_SPACE=/tmp; /usr/bin/lynx -dump "$NOTIFY?$SSH_HOST:$SSH_PREFIX/$DATE" 1&gt;&gt;log/lynx.log 2
&gt;&gt;log/lynx.log
        /bin/chmod -R 0700 $TMPDIR
    fi
}</pre>
<p>Lastly for this step, we create some additional logs $SPOOL/log/lynx.log and $SPOOL/log/scp.log</p>
<p><code>touch /var/spool/hylafax/log/scp.log<br />
touch /var/spool/hylafax/log/lynx.log<br />
chown uucp.uucp touch /var/spool/hylafax/log/scp.log<br />
chown uucp.uucp touch /var/spool/hylafax/log/lynx.log</code></p>
<p><strong>VI. </strong>Open up /etc/aliases and add the following:</p>
<p><code># alias for notification messages from HylaFAX servers<br />
faxman:         &lt;a valid email address where you want notifications sent out to&gt;<br />
FaxMaster: faxman</code></p>
<p>Close the aliases file and commit by:</p>
<p><code># newliases</code></p>
<p><strong>VII. </strong>You should be all set, fire up:</p>
<p><code>/usr/sbin/faxgetty &lt;your modem device i.e. ttySHSF0&gt;</code></p>
<p>… and fax away!</p>
<p><strong>VIII. </strong>Troubleshooting:</p>
<p>Wondering why your faxes aren’t being sent to remote server or your notify script not being called or failing? Check $SPOOL/log/lynx.log and $SPOOL/log/scp.log</p>
]]></content:encoded>
			<wfw:commentRss>http://dotmanila.com/blog/2008/05/automated-document-collection-via-fax-using-hylafax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

