Debian Sarge 3.1 & HylaFAX

Discussion in 'Server Operation' started by nenad, Mar 11, 2007.

  1. nenad

    nenad ISPConfig Developer

    Hi,

    just to save a LOT of troubles to anyone who is trying to make HylaFAX working with Debian Sarge 3.1 (on an ISPConfig system of course) I want to post resolution to problem:

    Code:
    server200:~# [B]faxstat[/B]
    Can not reach server at host "localhost", port 4559
    Right after installation HylaFAX works, but after first reboot of server or after changing some on config files and executing

    Code:
    /etc/init.d/hylafax restart
    It is not working anymore, and misteriosly refuses to start hfax daemon and notifies user about that with simple:
    So, on the other Debian machine I have compiled HylaFAX which is of course running semlessly. I copied hfaxd script into non-working environment where is HylaFAX installed from deb package, and now it is working as it should.

    To cut the story, here is solution:

    script /etc/init.d/hylafax

    should be substituted for this script:

    Code:
    #! /bin/sh
    #	$Id: hylafax.in,v 1.10 2006/06/02 17:27:30 aidan Exp $
    #
    # chkconfig: 2345 97 05
    #
    # description: HylaFAX(tm) is a sophisticated enterprise-strength fax
    #              package for class 1 and 2 fax modems on unix systems.
    #              This init script is the preferred way to start HylaFAX,
    #              but does not, by default, activate any modems. Consult
    #              the faxgetty(8) and faxmodem(8) man pages for more info.
    #
    # Warning, this file was automatically created by the HylaFAX configure script
    #
    # HylaFAX Facsimile Software
    #
    # Copyright (c) 1990-1996 Sam Leffler
    # Copyright (c) 1991-1996 Silicon Graphics, Inc.
    # HylaFAX is a trademark of Silicon Graphics
    # 
    # Permission to use, copy, modify, distribute, and sell this software and 
    # its documentation for any purpose is hereby granted without fee, provided
    # that (i) the above copyright notices and this permission notice appear in
    # all copies of the software and related documentation, and (ii) the names of
    # Sam Leffler and Silicon Graphics may not be used in any advertising or
    # publicity relating to the software without the specific, prior written
    # permission of Sam Leffler and Silicon Graphics.
    # 
    # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
    # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
    # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
    # 
    # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
    # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
    # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
    # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
    # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
    # OF THIS SOFTWARE.
    
    #
    # VERSION:	4.3.2
    # DATE:		Fri Mar  2 03:24:31 CET 2007
    # TARGET:	i686-pc-linux-gnu
    #
    
    #
    # fax server control
    #
    # NB: This script assumes faxgetty processes are managed by init
    #
    SPOOL=/var/spool/hylafax
    
    test -f $SPOOL/etc/setup.cache || {
        cat<<EOF
    
    FATAL ERROR: $SPOOL/etc/setup.cache is missing!
    
    The file $SPOOL/etc/setup.cache is not present.  This
    probably means the machine has not been setup using the faxsetup(8C)
    command.  Read the documentation on setting up HylaFAX before you
    startup a server system.
    
    EOF
        exit 1
    }
    . $SPOOL/etc/setup.cache
    
    # Just in case these are not in setup.cache yet
    if [ -z "$HFAXD_SERVER" ]; then
        HFAXD_SERVER=yes
    fi
    if [ -z "$FAXQ_SERVER" ]; then
        FAXQ_SERVER=yes
    fi
    if [ -z "$HFAXD_OLD_PROTOCOL" ]; then
        HFAXD_OLD_PROTOCOL=no
    fi
    if [ -z "$HFAXD_SNPP_SERVER" ]; then
        HFAXD_SNPP_SERVER=no
    fi
    
    IS_ON=/etc/chkconfig		# NB: chkconfig is IRIX- and Linux-specific
    FAXQ=$SBIN/faxq
    HFAXD=$LIBEXEC/hfaxd
    FAXQUIT=$SBIN/faxquit
    FAXPORT=hylafax			# designated port for new protocol
    SNPPPORT=444			# official port for SNPP
    
    if test ! -x $IS_ON ; then
        IS_ON=true
    fi
    
    if $IS_ON verbose ; then
        ECHO=echo
    else		# For a quiet startup and shutdown
        ECHO=:
    fi
    
    #
    # Figure out which brand of echo we have and define prompt
    # and printf shell functions accordingly.  Note that we
    # assume that if the System V-style echo is not present,
    # then the BSD printf program is available.  These functions
    # are defined here so that they can be tailored on a per-site,
    # etc. basis.
    #
    if [ `echo foo\\\c`@ = "foo@" ]; then
        # System V-style echo supports \r
        # and \c which is all that we need
        printf()
        {
           $ECHO "$*\\c"
        }
    elif [ "`echo -n foo`@" = "foo@" ]; then
        # BSD-style echo; use echo -n to get
        # a line without the trailing newline
        printf()
        {
           $ECHO -n "$*"
        }
    else
        # something else; do without
        printf()
        {
    	$ECHO "$*"
        }
    fi
    
    #
    #
    # killall -SIGNAL process-name
    #
    # Emulate the necessary functionality of the
    # killall program
    #
    killall()
    {
    	# NB: ps ax should give an error on System V, so we try it first!
    	pid="`ps ax 2>/dev/null | $AWK \"\
    		/[\/ (]$2[ )]/	{print \\$1;}
    		/[\/ ]$2\$/	{print \\$1;}\"`"
    	test "$pid" ||
    	    pid="`ps -e 2>/dev/null | $AWK \"/ $2[ ]*\$/ {print \\$1;}\"`"
    	test "$pid" && kill $1 $pid; return
    }
    
    case $1 in
    'start')
    	if $IS_ON fax && test -x $FAXQ; then
    	    if test $FAXQ_SERVER = yes ; then
    		killall -15 faxq
    	    fi
    	    if test $HFAXD_SERVER = yes ; then
    		killall -15 hfaxd
    	    fi
    	    printf "HylaFAX:"
                if test $FAXQ_SERVER = yes ; then
    	        $FAXQ; printf " faxq"
                fi
                if test $HFAXD_SERVER = yes ; then
    	        HFAXD="$HFAXD -i $FAXPORT"
    		HFAXMSG=" hfaxd"
    		if [ $HFAXD_OLD_PROTOCOL = yes ]; then
    	    	    HFAXD="$HFAXD -o 4557"
    		    HFAXMSG="$HFAXMSG (with old protocol"
    		else
    		    HFAXMSG="$HFAXMSG (without old protocol"
    		fi
    		if [ $HFAXD_SNPP_SERVER = yes ]; then
    	    	    HFAXD="$HFAXD -s $SNPPPORT"
    		    HFAXMSG="$HFAXMSG & with SNPP support)"
    		else
    		    HFAXMSG="$HFAXMSG & without SNPP support)"
    		fi
    		$HFAXD ; printf "$HFAXMSG"
                fi
    	    if test $FAXQ_SERVER != yes && test $HFAXD_SERVER != yes ; then
    		printf " not started (script disabled by configure)"
    	    fi
    	    $ECHO "."
    	fi
    	;;
    'stop')
    	$ECHO "Stopping HylaFAX Servers."
    	$FAXQUIT >/dev/null 2>&1
    	killall -15 hfaxd
    	;;
    'start_msg')
    	$ECHO "Starting HylaFAX Servers."
    	;;
    'stop_msg')
    	$ECHO "Stopping HylaFAX Servers."
    	;;
    *)
    	$ECHO "usage: hylafax {start|stop|start_msg|stop_msg}"
    	;;
    esac
    
    After that simply execute:

    Code:
    /etc/init.d/hylafax stop
    /etc/init.d/hylafax start
    
    note: there's no "restart" functionality within this script

    and executing of

    Code:
    faxstat
    command will return to you:

    Code:
    server200:~# faxstat
    Password:
    [B]HylaFAX scheduler on server200.web-hosting.co.yu: Running
    Modem ttyS0 (+38121402404): Running and idle[/B]
    server200:~#
    
    Now, if you use some client application like Hylafront (free one, I use it instead of Cypheus which is not free, but it is mentioned in Hylafax how-to http://www.howtoforge.com/linux_hylafax_server), you can login and check and setup your faxing. Of course you have to setup username and pass to allow connecting of clients to server. For printing from Windows desktops you can use http://winprinthylafax.sourceforge.net/

    Tip: HylaFAX uses port 4559 for data communication, but it sends data for fax over RANDOM high number unprivileged port. It will save you a lot of headache if you disable firewall while checking you HylaFAX installation. Later you have to find work arround for this "random high port" issue.

    By the way, debian installation of HylaFAX provides receiving of faxes in PDF format "out-of-box". There's no need for additional setup as described here http://www.howtoforge.com/linux_hylafax_server ,
    except you have to setup filetype and default recipient for incoming faxes in

    /var/spool/hylafax/etc/FaxDispatch


    FILETYPE=pdf;
    SENDTO=username@of.faxmaster.com;
     
    Last edited: Mar 12, 2007

Share This Page