Installing Hylafax Fax Server as a Printer

A print fax server allows you and your users to send faxes by selecting 'fax' as their printer, and using the same commands they would normally use for printing on a regular printer. This reduces system maintenance and makes their learning curve easier, and also obviates the need for them to get out of their chair and walk all the way over to the fax machine in order to fax something. Oh, do I sound cynical already?

To install Hylafax, you need the following files:
 hylafax-4.1beta3.tar.gz         - Unix fax server and client
 macflex-latest.hqx              - Mac fax client
 whfc-1.0.8_setup_en.exe         - Windows fax client 
You also need a working Samba installation to use Hylafax as a printer for Windows clients.

There is an alternative method usind mgetty+sendfax and printfax.pl that is described in Professional Linux Deployment. However, although this book is not too bad for a mass-market computer book, it doesn't give a listing of the crucial 'faxfilter' file and makes no mention of how to print from a Mac or Unix system. I also couldn't find any documentation on this from the printfax website, so I did not try this method.

Installation of Hylafax

  1. Make sure your faxmodem is installed and working, and find out what serial port it is on.
  2. tar -xzvf hylafax-4.1beta3.tar.gz
  3. cd hylafax-4.1beta3
  4. configure
  5. make
  6. su
  7. make install
  8. faxsetup - This is an interactive script for configuring hylafax. Most of the defaults can be used. The interaction is shown below.
    Setup program for HylaFAX (tm) 4.1beta2.
    Created for i386-suse-linux on Sat Jul 29 14:15:14 GMT 2000.
    Reading cached parameters from /var/spool/fax/etc/setup.cache.
    Checking system for proper client configuration.
    Checking system for proper server configuration.
    Warning: /usr/sbin/egetty does not exist or is not an executable program!
    The file:
           /usr/sbin/egetty
    does not exist or this file is not an executable program.  The
    HylaFAX software optionally uses this program and the fact that
    it does not exist on the system is not a fatal error.  If the
    program resides in a different location and you do not want to
    install a symbolic link for /usr/sbin/egetty that points to your program
    then you must reconfigure and rebuild HylaFAX from source code.
    
    Make /var/spool/fax/bin/ps2fax a link to /var/spool/fax/bin/ps2fax.gs.
    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]? 
    Area code []? 301
    Long distance dialing prefix [1]? 
    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]? 1000
    Syslog facility name for ServerTracing messages [daemon]? 
    
    The non-default scheduler parameters are:
        AreaCode:               301
        MaxSendPages:           1000
    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/rc.d/init.d/hylafax start
    HylaFAX: not started (script disabled by configure).
    
    You do not appear to have any modems configured for use.  Modems are
    configured for use with HylaFAX with the faxaddmodem(1M) command.
    Do you want to run faxaddmodem to configure a modem [yes]? 
    Serial port that modem is connected to []? ttyS0
    Hmm, there does not appear to be an fuser command on your machine.
    This means that I am unable to insure that all processes using the
    modem have been killed.  I will keep going, but beware that you may
    have competition for the modem.
    
    Ok, time to setup a configuration file for the modem.  The manual
    page config(4F) 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]? 
    Area code [415]? 301
    Phone number of fax modem [+1.999.555.1212]? 13015551212
    Local identification string (for TSI/CIG) ["NothingSetup"]? Sh-Hole Institute
    Long distance dialing prefix [1]? 
    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 ttyS0 [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]? 200
    Syslog facility name for ServerTracing messages [daemon]? 
    Set UID to 0 to manipulate CLOCAL [""]? 
    
    The non-default server configuration parameters are:
       CountryCode:            1
       AreaCode:               301
       FAXNumber:              13015551212
       LongDistancePrefix:     1
       InternationalPrefix:    011
       DialStringRules:        etc/dialrules
       SessionTracing:         11
       RingsBeforeAnswer:      1
       SpeakerVolume:          off
       GettyArgs:              "-h %l dx_%s"
       LocalIdentifier:        Sh-Hole Institute
       TagLineFont:            etc/lutRS18.pcf
       TagLineFormat:          "From %%l|%c|Page %%P of %%T"
       MaxRecvPages:           200
    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.
    [1]+  Terminated              ( trap "" 0 1 2; while true; do
        sleep 10; echo ""; echo "Hmm, something seems to be hung, check your modem eh?";
    done )
    
    Hmm, this looks like a Class 1 modem.
    Product code (ATI0) is "Zoom V.90 Serial s052099g -I Z207".
    DTE-DCE flow control scheme [default]? 
    Modem manufacturer is "Unknown".
    Modem model is "Unknown".
    
    Using prototype configuration file class1...
    
    There is no prototype configuration file for your modem, so we will
    have to fill in the appropriate parameters by hand.  You will need the
    manual for how to program your modem to do this task.  In case you are
    uncertain of the meaning of a configuration parameter you should
    consult the config(4F) manual page for an explanation.
    
    Note that modem commands must be specified exactly as they are to be
    sent to the modem.  Note also that quote marks (") will not be displayed
    and will automatically be deleted.  You can use this facility to supply
    null parameters as "".
    
    Finally, beware that the set of parameters is long.  If you prefer to
    use your favorite editor instead of this script you should fill things
    in here as best you can and then edit the configuration file
                 "/var/spool/fax/etc/config.ttyS0"
    after completing this procedure.
    
    Warning, the prototype configuration for your modem uses a different
    DTE-DCE communication rate () than the rate that you have
    selected (38400).  Unless this prototype configuration file is setup
    to automatically switch baud rates for facsimile communication, 38400
    may not work correctly for sending and receiving facsimile: check your
    modem manual to make sure that 38400 is acceptable.
    
    Command to enter Class 1 [AT+FCLASS=1]? 
    Extra bytes in a received HDLC frame [4]? 
    Maximum time to wait for OK after aborting a receive (ms) [200]? 
    Maximum wait for initial identification frame (ms) [40000]? 
    Delay before sending post-page message (ms) [75]? 
    Delay between sending TCF and ack/nak (ms) [75]? 
    Delay before sending DCS and TCF (ms) [75]? 
    Delay after failed training (ms) [1500]? 
    
    The modem configuration parameters are:
         Class1Cmd:              AT+FCLASS=1
         Class1FrameOverhead:    4
         Class1RecvAbortOK:      200
         Class1RecvIdentTimer:   40000
         Class1SendPPMDelay:     75
         Class1SendTCFDelay:     75
         Class1TCFMaxNonZero:    10
         Class1TCFMinRun:        1000
         Class1TCFResponseDelay: 75
         Class1TrainingRecovery: 1500
    
    Are these ok [yes]? 
    
    Warning, the prototype configuration for your modem uses a different
    DTE-DCE communication rate () than the rate that you have
    selected (38400).  Unless this prototype configuration file is setup
    to automatically switch baud rates for facsimile communication, 38400
    may not work correctly for sending and receiving facsimile: check your
    modem manual to make sure that 38400 is acceptable.
    
    Creating new configuration file /var/spool/fax/etc/config.ttyS0...
    Creating fifo /var/spool/fax/FIFO.ttyS0 for faxgetty... done.
    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:            1
         AreaCode:               301
         LongDistancePrefix:     1
        InternationalPrefix:    011
        DialStringRules:        etc/dialrules
        MaxSendPages:           1000
    
    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(1M) (if you have a send-only environment)
    or configure init to run faxgetty on ttyS0.
    Do you want to run faxaddmodem to configure another modem [yes]? no
    
    You do not appear to be using faxgetty to notify the HylaFAX scheduler
    about new modems and/or their status.  This means that you must use the
    faxmodem program to inform the new faxq process about the modems you
    want to have scheduled by HylaFAX.  Beware that if you have modems that
    require non-default capabilities specified to faxmodem then you should
    read faxmodem(1M) manual page and do this work yourself (since this
    script is not intelligent enough to automatically figure out the modem
    capabilities and supply the appropriate arguments).
    
    Should I run faxmodem for each configured modem [yes]? 
    /usr/sbin/faxmodem ttyS0
    
    Done verifying system setup. 
  9. Then edit /etc/inittab, and add:
     S0:23:respawn:/usr/local/sbin/faxgetty /dev/ttyS0 
    Make sure /usr/local/sbin/faxgetty is present and executable. Note that SuSE installs a different faxgetty in /usr/lib/fax/ as well.
  10. init q
  11. On SuSE Linux, edit /etc/rc.config and change START_HYLAFAX to "yes". On other systems, this file may be different.
  12. Check /var/spool/fax/etc/setup.cache to make sure the following are set to 'yes' and not '1':
        FAXQ_SERVER='yes'
        HFAXD_SERVER='yes'   
    The default value of '1' doesn't work in the startup script.
  13. Then, run '/sbin/init.d/hylafax start' .
  14. ps -aux | grep fax should show:
       /usr/local/sbin/faxgetty /dev/ttyS0
       /usr/sbin/faxq
       /usr/lib/fax/hfaxd -i hylafax 
  15. Finally, as root, setup the cron jobs that clean out the queue.
    export VISUAL=pico
    crontab -e
    
    # crontab file
    0   *    *    *    *    /usr/local/sbin/faxqclean
    25   23    *    *    *  sh /usr/local/sbin/faxcron | mail FaxMaster
    Make sure you know who 'FaxMaster' is in your /etc/aliases.
  16. cat /var/spool/fax/status/ttyS0 - should say "Running and idle" Note that there is a fifo in this directory. This is used to send the fax to the serial port.
  17. Now you can sit back and wait for the telemarketers to discover that you have a fax machine. This takes about five minutes, after which your printer will automatically start spewing out junk advertisements.
Now that hylafax is running, the next step is to figure out how to make it do something. You use the following commands to control hylafax:
  1. sendfax, a program to submit outgoing facsimile; Your users can use numeric or alpha characters, e.g. 1-800-GotMilk.
  2. sendpage, a program to submit alpha-numeric messages to SNPP servers
  3. faxstat, a program obtain status information about HylaFAX servers;
  4. faxrm, a program to remove jobs and documents
  5. faxalter, a program to change parameters of queued jobs
  6. fax2ps, a program that converts facsimile documents to POSTSCRIPT so that they may be viewed with a POSTSCRIPT previewer or printed on a POSTSCRIPT printer
Test sending faxes from the Unix command line.
 sendfax -vv -d 5551212 /etc/passwd 
The more common options are:
    -B modem speed 
    -c comments - adds comments to fax cover sheet
    -D notify sender by email when fax is delivered
    -d phone number to dial
    -f from   e.g -f "Joe Blow"
    -h [modem@]host[:port] -if no host, it uses localhost
    -n no cover page
    -R notify sender by email if fax is delivered or requeued.
    -r regarding - a string added to cover page
    -t tries - max no of tries to send
    -v, -vv verbose 
Change /usr/local/lib/fax/faxcover.ps to create a site-specific cover sheet. Most of the important files are in /usr/local/lib/fax/ and /var/spool/fax/.

Unix, Windows and Mac clients

Incoming faxes are stored in /var/spool/fax/recvq/fax*.tif. Users can have all their outgoing email sent by fax - see ~/hylafax/faxmail/mailfax.sh. This is not terribly useful, however. Incoming faxes can be sent to a specific user based on the caller's phone number by editing the file ??????.

To print incoming faxes automatically, make sure lpr printing is working and edit
 /var/spool/fax/bin/faxrecvd 
and add the following lines at the end:
       /usr/bin/tiff2ps $1 > fax.ps
       lpr -Pmyprinter fax.ps
       rm -f fax.ps
       rm -f $1 

The server should have the following in /etc/printcap:
     fax|faxprint:\
             :lp=/dev/null:\
             :sd=/var/spool/lpd/faxspool:\
             :lf=/var/spool/lpd/faxspool/err.log:\
             :if=/usr/local/etc/mgetty+sendfax/faxfilter:\
             :mx#0:\
             :sh:\
             :sf: 
/usr/local/etc/mgetty+sendfax/faxfilter should be something like:
     #!/bin/sh
     while [ $# -gt 0 ]; do
          if [ "$1" = "-n" ]; then
             UNAME=$2
          fi
          TEMP=`echo $1 | cut -c1-2`
          if [ $TEMP = "-i" ]; then
             NUMBER=`echo $1 | sed s/-i//`
          fi
       shift
     done
     cat > /tmp/fax_$UNAME.ps
     chmod 644 /tmp/fax_$UNAME.ps
     sendfax -d$NUMBER /tmp/fax_$UNAME.ps 

Unix client printing

Unix clients can print using the sendfax command, or by adding an entry for the fax in their /etc/printcap. This allows them to fax without having to install hylafax. They can fax a document by typing
 lpr -Pfax -i915551212 mydocument 
The Unix client should have the following in its /etc/printcap:
fax:\
        :lp=:/dev/null:\
        :rm=196.100.222.22:\
        :rp=faxprint:\
        :sh:\
        :sf:\
        :if=/usr/lib/lpf:\
        :af=/usr/lib/lpf:\
        :sd=/usr/spool/lpd/fax:\
        :lf=/usr/spool/lpd/fax/errs:\
        :mx#0: 
Note that 'faxprint' must be in the host computer's /etc/printcap as shown earlier, and /etc/hosts.lpd must contain the client's hostname or IP number, e.g.
      host1.my_hostname.com
      *.my_hostname.com 
/usr/lib/lpf is nothing more than a filter that adds a line feed after each carriage return character. Note that the ^M in the 5th line is the ctrl-M character, not ^ followed by an M. Both lpf and faxfilter must be executable.
#!/bin/sh
if [ "$1" = c ]; then
   cat
else
   sed -e s/$/^M/
fi
# The echo -ne assumes bash
#echo -ne \\f 

The sequence of actions is:

  1. Remote user filters print job through lpf.
  2. Remote user sends print job by lpr to host.
  3. Host lpd accepts remote print job if client is in /etc/hosts.lpd .
  4. lpd filters print job through faxprint.
  5. faxprint parses the -i argument to obtain the phone number and spools fax job to /tmp. (Ideally, it should go to a more secure location).
  6. faxprint calls sendfax (which is part of hylafax) with correct arguments for phone number.
As indicated in the printcap(5) man page, the if filter is invoked with arguments:
     if [-c] -wwidth -llength -iindent -n login -h host acct-file 
Thus, only w,l,i,n, or h can be used by the remote client to convey the phone number when the if (input filter) method described here is used. In particular, '-J' cannot be used.

Windows client printing

Windows users can print using whfc from http://www.transcom.de/whfc . With a little setup, they too can send faxes by clicking on the appropriate printer icon.

Server setup

  1. Add a user ,e.g. "faxuser" and give it a password.
  2. Edit /var/spool/fax/etc/hosts.hfaxd and add the line:
     faxuser@my_hostname.com:101:GB8k61xX80f3o: 
    If you paste the encrypted password from your shadow file between the two colons (as was done here), they will need to enter a password. See man hosts.hfaxd for details (Note: this is not a valid password). Note that you have to escape any wildcard characters.
  3. Check which port number hylafax is using in /sbin/init.d/hylafax.
Client setup
  1. Click on whfc-1.0.8_setup_en.exe icon to run setup
  2. Go to Windows printer installation
  3. Choose local printer
  4. Select WHFCFAX from the list
  5. It will say "Server does not have printer driver". Click OK.
  6. Select Applewriter 16/1600PS as the printer driver.
  7. Click OK.
  8. Change printer's name to 'fax'
  9. Make sure it is not the default printer.
  10. Windows 2000 users need to start whfc manually by clicking on it. It can be left minimized on the Task Bar, or added to the "autostart" group.
  11. Before printing a test page, click on whfc and configure it. It might start out in German.
    1. Fax...System preferences (or systemeinstellungen)
               servername: malaria
               port nummer: 4559 
    2. Fax...User preferences (or benutzereinstellungen)
               name: faxuser
               Language (Sprache): default
               e-mail: [enter your email address]
               Send Email (E-mail Bestatigung)
                        None            Keine
                        When delivered  Nach dem Versenden
                        Always          Immer
                  (select one)
               Page size (SeitengroBe): Letter 
  12. Put whfc on the task bar.
  13. Print a test page. The Fax dialog box will appear. Type the fax number of a fax machine to send it to. Be sure to select "letter" not "A4" as the paper size.
  14. If you have problems, an online manual is available.

Macintosh client printing

Use macflex-latest.hqx.

Back