Fax server with Ubuntu server 9.10, Conexant drivers, Hylafax and Avantfax

Discussion in 'HOWTO-Related Questions' started by letsharehowto, Dec 17, 2009.

  1. letsharehowto

    letsharehowto New Member

    Today I tell you how to install, config box which can received fax, send fax, remind you when fax coming via email, forward fax via email (look like fax2email) with Ubuntu server 9.10, Conexant drivers, Hylafax and Avantfax.

    I don't know how box run and please don't ask me why and why :)
    My english no good, so sorry.

    My hardware:
    -Cheap desktop: Compaq Evo D510 Desktop Computer - Intel Pentium 4 2.4GHz, 512MB DDR, 40GB HDD, CD-ROM, Windows XP Home (http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=5315098&CatId=2628)
    -Two cheap HSF fax modem: D-LINK DFM-562IS (http://www.vitinhphongvu.com/index.php?ava=productone&sp=1937)
    -I'm working in Viet Nam. My ISP: VNN

    When I try Ubuntu server 9.04, box send fax good but when box received fax: first fax received good, second fax can not received because modem fax do not turn on auto answer. Modem ring ring and ring...

    I try Postfix, Postfix don't work. I use Sendmail, Sendmail work good. I don't need config any more, only type: apt-get install sendmail. Thats'it.

    We have three steps:
    -Step one: Setup Ubuntu server 9.10.
    -Step two: Config HSF fax modem and install Hylafax.
    -Step three: Install Avantfax.

    Step one: Setup Ubuntu server 9.10:
    ^^^^^^^^

    Connect internet.
    Setup box with Ubuntu server 9.10. If you don't know how, you can google.

    Note:

    -If you don't want Ubuntu Startup slows down at Starting Mail Transport Agent (MTA) sendmail you have to choose long hostname. Example: "tom.localdomain". If you choose short name: "tom", box boot up, box Forward fax via email and box remind you when fax come is very slow.
    -Software selection: LAMP Server and OpenSSH Server
    -Password for the MYSQL "root" user: 111111

    Step two: Config HSF fax modem and install Hylafax:
    ^^^^^^^^

    Set root password. Code:

    sudo passwd root
    exit

    Logon with root and latter do everything with root too.
    Set static IP. Code:

    nano /etc/network/interfaces

    Replace the “iface eth0 inet dhcp” with this:

    ###Begin###############################

    iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

    ###End################################

    Reset connection. Code:

    ifdown eth0 && ifup eth0

    Upgrade box. Code:

    apt-get update
    apt-get upgrade

    You have to reboot box. Code:

    reboot

    Logon root, install sendmail and some software. Code:

    apt-get install mc gcc make unzip sendmail

    Find kernel version. Code:

    uname -r

    My case: 2.6.31-14-generic-pae. I search and download ALSA driver from http://www.linuxant.com/alsa-driver/downloads-ubuntu-x86.php. Code:

    wget http://www.linuxant.com/alsa-driver....3_k2.6.31_14_generic_pae_ubuntu_i386.deb.zip

    Unzip file. Code:

    unzip alsa-driver-linuxant_1.0.20.3_k2.6.31_14_generic_pae_ubuntu_i386.deb.zip

    Install file. Code:

    dpkg -i alsa-driver-linuxant_1.0.20.3_k2.6.31_14_generic_pae_ubuntu_i386.deb

    Remove file. Code:

    rm *.deb

    Follow website https://help.ubuntu.com/community/DialupModemHowto/Conexant, I download. Code:

    wget http://www.bargweb.net/images/2009/november/hsfmodem-7.80.02.05-DiacoEdition.zip

    Unzip file. Code:

    unzip hsfmodem-7.80.02.05-DiacoEdition.zip

    Install. Code:

    cd hsfmodem-7.80.02.05-DiacoEdition
    make install

    Run hsfconfig (I choose default all of them). Code:

    hsfconfig

    Remove file. Code:

    cd
    rm *.zip

    Install Hylafax. Code:

    apt-get install hylafax-server

    I have two fax modem cards. The first one I use ttySHSF0, class 1.0. Second one: ttySHSF1, class 1.0. When setup finish first one, box ask me want config another one, I say yes, second one I say no. I keep default allmost. Fax setup. Code:

    faxsetup

    Reboot box. Code:

    reboot

    Step three: Install Avantfax.
    ^^^^^^^^^^

    Logon root. Check modem work or not. Code:

    faxstat -a -s

    If modem work, box say:

    root@tom:~# faxstat -a -s
    HylaFAX scheduler on tom.localdomain: Running
    Modem ttySHSF0 (+1.999.555.1212): Running and idle
    Modem ttySHSF1 (+1.999.555.1212): Running and idle

    Install some software for Avantfax. Code:

    apt-get install apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libsqlite3-0 php5-cli php5-common mysql-server imagemagick libtiff4-dev netpbm libnetpbm10-dev libungif-bin libungif4-dev sudo php-mail php-mail-mime php-file php-db php5-mysql psutils wdiff expect rsync php5-dev libmagic-dev php5-cgi

    Install fileinfo. Code:

    pecl install fileinfo
    pear install Mail Net_SMTP Mail_mime MDB2_driver_mysql fileinfo

    Download Avantfax from http://www.avantfax.com. Code:

    wget http://downloads.sourceforge.net/avantfax/avantfax-3.1.6.tgz?use_mirror=osdn

    Unzip file. Code:

    tar -xf avantfax-3.1.6.tgz

    Change something file debian-install.sh. Code:

    cd avantfax-3.1.6
    nano debian-install.sh

    Delete everything then replace with:


    ###Begin###########################################################

    FAXDOMAIN=fax.mydomain.com
    INSTDIR=/var/www/avantfax
    HYLADIR=/usr/sbin
    SPOOL=/var/spool/hylafax
    USER=avantfax
    PASS=d58fe49
    DB=avantfax
    HTTPDUSER=www-data
    HTTPDGROUP=www-data

    #!/bin/sh
    #
    # AvantFAX install script for Debian
    # This script will configure /etc/sudoers and the HylaFAX hyla.conf, config, config.<devid> files
    # Only run once
    #

    # CHECK IF HYLAFAX IS INSTALLED

    echo "Checking for HylaFAX installation"

    hyla=`which sendfax`
    if [ "$?" -ne "0" ]; then
    echo You must install and configure HylaFAX first
    exit
    fi

    . ./debian-prefs.txt


    ## SETUP SMARTY
    chmod 0770 avantfax/includes/templates/admin_theme/templates_c/ avantfax/includes/templates/admin_theme/cache/ avantfax/includes/templates/main_theme/templates_c/ avantfax/includes/templates/main_theme/cache/
    chown $HTTPDUSER:$HTTPDGROUP avantfax/includes/templates/admin_theme/templates_c/ avantfax/includes/templates/admin_theme/cache/ avantfax/includes/templates/main_theme/templates_c/ avantfax/includes/templates/main_theme/cache/

    chmod 0755 avantfax/includes/faxcover.php avantfax/includes/faxrcvd.php avantfax/includes/notify.php avantfax/tools/update_contacts.php avantfax/tools/faxcover.php avantfax/includes/avantfaxcron.php avantfax/includes/dynconf.php

    cp avantfax/includes/local_config-example.php avantfax/includes/local_config.php


    # echo "AdminGroup: apache" >> /etc/hylafax/hfaxd.conf

    # SETUP AVANTFAX JOBFMT

    cat >> /etc/hylafax/hyla.conf << EOF

    #
    ## JobFmt for AvantFAX
    #
    JobFmt: "%-3j %3i %1a %15o %40M %-12.12e %5P %5D %7z %.25s"

    EOF

    # INSTALL AVANTFAX

    mv avantfax $INSTDIR
    chown -R $HTTPDUSER.$HTTPDGROUP $INSTDIR
    chmod -R 0770 $INSTDIR/tmp $INSTDIR/faxes
    chown -R $HTTPDUSER.uucp $INSTDIR/tmp $INSTDIR/faxes


    # IMPORT MYSQL DATABASE

    /etc/init.d/mysql start

    echo "## Creating AvantFAX MySQL database ##"
    mysql --user=root --password=111111 -e "GRANT ALL ON $DB.* TO $USER@localhost IDENTIFIED BY \"$PASS\"" mysql
    mysqladmin --default-character-set=utf8 --user=$USER --password=$PASS create $DB
    mysql --user=$USER --password=$PASS $DB < create_tables.sql
    mysqlshow --user=$USER --password=$PASS $DB

    # SYMLINK AVANTFAX SCRIPTS

    ln -s $INSTDIR/includes/faxrcvd.php $SPOOL/bin/faxrcvd.php
    ln -s $INSTDIR/includes/dynconf.php $SPOOL/bin/dynconf.php
    ln -s $INSTDIR/includes/notify.php $SPOOL/bin/notify.php

    mv $HYLADIR/bin/faxcover $HYLADIR/bin/faxcover.old
    ln -s $INSTDIR/includes/faxcover.php $HYLADIR/bin/faxcover

    # FIX FILEINFO

    ln -s /usr/share/file/magic* /usr/share/misc/

    # SETUP SUDO PERMISSIONS

    echo "Setting up sudo"

    cat /etc/sudoers | grep -v requiretty > /tmp/sudoers
    echo "$HTTPDUSER ALL= NOPASSWD: /sbin/reboot, /sbin/halt, /usr/sbin/faxdeluser, /usr/sbin/faxadduser -u * -p * *" >> /tmp/sudoers
    mv /etc/sudoers /etc/sudoers.orig
    mv /tmp/sudoers /etc/sudoers
    chmod 0440 /etc/sudoers
    chown root.root /etc/sudoers

    # Make backup of HylaFAX configuration

    mkdir /etc/hylafax/abackup
    cp /etc/hylafax/config* /etc/hylafax/abackup/

    # CONFIGURE MODEMS TO USE AVANTFAX

    for i in `ls /etc/hylafax/config.*`; do
    if [ "$i" != "/etc/hylafax/config.sav" ]; then
    if [ "$i" != "/etc/hylafax/config.devid" ]; then
    tilde=`echo $i | grep '~'`
    if [ "$?" -eq "1" ]; then
    if [ ! -L $i ]; then
    cat >> $i << EOF

    #
    ## AvantFAX
    #
    FaxRcvdCmd: bin/faxrcvd.php
    DynamicConfig: bin/dynconf.php
    UseJobTSI: true

    EOF
    fi
    fi
    fi
    fi
    done

    cat >> /etc/hylafax/config << EOF

    #
    ## AvantFAX
    #
    NotifyCmd: bin/notify.php

    EOF

    # ADD MODEMS TO DATABASE

    for i in `ls /etc/hylafax/config.*`; do
    if [ "$i" != "/etc/hylafax/config.sav" ]; then
    if [ "$i" != "/etc/hylafax/config.devid" ]; then
    tilde=`echo $i | grep '~'`
    if [ "$?" -eq "1" ]; then
    if [ -f $i ]; then
    modem=`echo $i | awk -F'/' '{print $6}' | awk -F'.' '{print $2}'`

    # ADD MODEMS TO AVANTFAX DATABASE
    mysql --user=$USER --password=$PASS -e "INSERT INTO Modems SET device='$modem', alias ='$modem'" $DB

    echo "Configuring $modem for AvantFAX"
    fi
    fi
    fi
    fi
    done

    # ADD CRONTAB ENTRIES

    echo "Setting up /etc/cron.d/avantfax"
    printf "0 0 * * *\t$INSTDIR/includes/avantfaxcron.php -t 2\n" > /etc/cron.d/avantfax

    echo -e "Installation complete\n\n"

    IP=`/sbin/ifconfig eth0 | grep "inet addr" | awk -F' ' '{print $2}' | awk -F':' '{print $2}'`

    echo -e "Log into the Administrative interface at: http://$IP/admin/"
    echo -e "Username: admin\nPassword: password"
    # DONE #

    ###End########################################################

    Install Avantfax. Code:

    ./debian-install.sh

    Change /etc/apache2/sites-enabled/000-default. Code:

    nano /etc/apache2/sites-enabled/000-default

    Replace: DocumentRoot /var/www by: DocumentRoot /var/www/avantfax
    Replace: <Directory /var/www/> by: <Directory /var/www/avantfax/>

    Save file and quit

    Change crontab. Code:

    crontab -e

    Add these line at bottom:

    ###Begin########################################

    # runs once an hour to update the phone book
    0 * * * * /var/www/avantfax/includes/phb.php
    # runs once a day to remove old files
    0 0 * * * /var/www/avantfax/includes/avantfaxcron.php -t 2

    ###End#########################################

    Save file and quit

    Reboot box. Code:

    reboot

    Logon root and setup hylafax users. Code:

    /usr/sbin/faxadduser -f newhosts -a pwd www-data
    /usr/sbin/faxdeluser localhost
    /usr/sbin/faxdeluser 127.0.0.1
    echo 127.0.0.1 >> newhosts
    echo localhost >> newhosts
    cat /etc/hylafax/hosts.hfaxd >> newhosts
    cat newhosts > /etc/hylafax/hosts.hfaxd
    rm -f newhosts

    Reboot box. Code:

    reboot

    Now you can access fax server: http://192.168.1.10/admin
    First time you have to change admin's password, then create Categories, create Modem (Example fax modem 1: Device*: ttySHSF0, Alias*: sale, Contact: [email protected], Category: Category1. Example fax modem 2: Device*: ttySHSF1, Alias*: support, Contact: [email protected], Category: Category2).
    Return dashboard if you see after sale and support say [Please wait], you get back server, logon root and run some code again (I don't know why):


    /usr/sbin/faxadduser -f newhosts -a pwd www-data
    /usr/sbin/faxdeluser localhost
    /usr/sbin/faxdeluser 127.0.0.1
    echo 127.0.0.1 >> newhosts
    echo localhost >> newhosts
    cat /etc/hylafax/hosts.hfaxd >> newhosts
    cat newhosts > /etc/hylafax/hosts.hfaxd
    rm -f newhosts

    Get back web brownser, reload page, if you see after sale and support say [Idle] with blue color => good. Now you can send, recived fax and send fax via email

    Thanks:
    http://ubuntu.com
    http://www.hylafax.org
    http://www.avantfax.com
    https://help.ubuntu.com/community/DialupModemHowto/Conexant
    http://www.linuxant.com/alsa-driver/downloads-ubuntu-x86.php
    http://www.howtoforge.com/build-a-hylafax-server-with-avantfax-on-debian-etch
    http://www.zyxware.com/articles/641...at-starting-mail-transport-agent-mta-sendmail
    And thank you http://www.howtoforge.com very much. I learn alot from you.
     
  2. letsharehowto

    letsharehowto New Member

    Note:
    When you run hsfconfig, hsfconfig ask you Please enter region name for modem unit 0, you choose USA. In my case, when I choose VIETNAM, fax modem card only answer fax on first call, the second call, fax modem only ring, don`t answer fax.
    Do not install on cloud box, ex: vmware
     
  3. xiaoanri

    xiaoanri New Member

    email not working

    thanks so much for the tutorial, i followed the instructions step by step, the server was set up and we are able to send and receive faxes without problem---well there is one problem: the email function is not working, we can send and receive faxes on the avantfax web page only. any ideas?
     
  4. jongerard

    jongerard New Member



    I've had the similar problem... any suggestions, anyone???
     
  5. muneer26

    muneer26 New Member

    Avant Fax

    Can anybody tellme how to install Avant Fax on Centos Please help me Step by step because i dont know anything on Avant Fax
     

Share This Page