Update - Hylafax + IAXmodem + Avantfax

Discussion in 'General' started by wholly, May 22, 2009.

  1. wholly

    Joined:
    Sep 6, 2008
    Messages:
    14
    Likes Received:
    0
    Does this code need much else added to work with Elastix> !

    thanks

    wayne


    Code:
    #!/bin/sh
    #       This program is free software; you can redistribute it and/or modify
    #       it under the terms of the GNU General Public License as published by
    #       the Free Software Foundation; either version 2 of the License, or
    #       (at your option) any later version.
    #
    #       This program is distributed in the hope that it will be useful,
    #       but WITHOUT ANY WARRANTY; without even the implied warranty of
    #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #       GNU General Public License for more details.
    #
    #       You should have received a copy of the GNU General Public License
    #       along with this program; if not, write to the Free Software
    #       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
    #       MA 02110-1301, USA.
    
    #Joe Roper 12.02.2009
    # Based on a script written by Phone User
    #http://pbxinaflash.com/forum/showthread.php?t=3093
    
    #Install Fax
    
    clear
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING"
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo "This script assumes you have not changed the default asteriskuser password For MySQL-updated for elastix"
    echo "If you have, e.g. if you use PBX-Management, press CTRL-C to exit"
    echo "Then change the MySQL asterisk password in the script to suit your installation."
    echo " "
    echo "If IAXModem/Hylafax/Avantfax is already installed, then you"
    echo "should inspect and modify this script, or your installation before executing it."
    echo " "
    echo "When prompted, go with the defaults - they should be changed via Webmin later "
    echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
    read -p "Press any key to continue or ctrl-C to exit"
    
    #Change passw0rd below for your MySQL asteriskuser password if you have changed it from the default.
    MYSQLASTERISKUSERPASSWORD=eLaStIx.2oo7
    
    
    LOAD_LOC=/var/pbx_load/
    
    cd $LOAD_LOC
    
    # install some dependencies
    yum -y install ghostscript ghostscript-fonts sharutils
    
    wget ftp://ftp.hylafax.org/binary/linux/redhat/RPMS/i386/hylafax-4.4.4-1rhel5.i386.rpm
    wget http://mesh.dl.sourceforge.net/sourceforge/iaxmodem/iaxmodem-1.2.0.tar.gz
    wget http://www.fonicaprojects.com/downloads/extras/avantfax.tar.gz
    wget http://www.fonicaprojects.com/downloads/extras/ico_fax.png
    wget http://www.tecchio.net/webmin/hylafax/hylafax_mod-1.8.2.wbm.gz
    
    #Install Hylafax first so that the directories are in place
    rpm -Uvh $LOAD_LOC/hylafax-4.4.4-1rhel5.i386.rpm
    
    
    #INstall IAXMODEMS 0->3
    
    cd /usr/src
    tar zxfv $LOAD_LOC/iaxmodem-1.2.0.tar.gz
    cd iaxmodem-1.2.0
    ./configure
    make
    mkdir /etc/iaxmodem/
    
    mkdir /var/log/iaxmodem
    touch /var/log/iaxmodem/iaxmodem.log
    
    COUNT=0
    while [ $COUNT -lt 4 ]; do
           echo "Number = $COUNT"
           touch /etc/iaxmodem/iaxmodem-cfg.ttyIAX$COUNT
    	touch /var/log/iaxmodem/iaxmodem-cfg.ttyIAX$COUNT
           echo "
    device /dev/ttyIAX$COUNT
    owner uucp:uucp
    mode 660
    port 457$COUNT
    refresh 300
    server 127.0.0.1
    peername iax-fax$COUNT
    cidname Fonica PABX
    cidnumber +0000000000$COUNT
    codec ulaw
    " > /etc/iaxmodem/iaxmodem-cfg.ttyIAX$COUNT
    
    #Setup IAX Registrations
    echo "
    [iax-fax$COUNT]
    type=friend
    host=127.0.0.1
    port=457$COUNT
    context=from-internal
    disallow=all
    allow=ulaw
    jitterbuffer=no
    qualify=yes
    deny=0.0.0.0/0.0.0.0
    permit=127.0.0.1/255.255.255.0
    " >> /etc/asterisk/iax_custom.conf
    
    #Setup Hylafax Modems
    cp /usr/src/iaxmodem-1.2.0/config.ttyIAX /var/spool/hylafax/etc/config.ttyIAX$COUNT
    
    echo "
    t$COUNT:23:respawn:/usr/sbin/faxgetty ttyIAX$COUNT > /var/log/iaxmodem/iaxmodem.log
    " >> /etc/inittab
    
    
    COUNT=$((COUNT + 1))
    done
    
    chown -R uucp:uucp /etc/iaxmodem/
    chown uucp:uucp /var/spool/hylafax/etc/config.ttyIAX*
    
    
    touch /etc/logrotate.d/iaxmodem
    echo "
    /var/log/iaxmodem/*.log {
        notifempty
        missingok
        postrotate
            /bin/kill -HUP `cat /var/run/iaxmodem.pid` || true
        endscript
    }
    " > /etc/logrotate.d/iaxmodem
    
    
    cp iaxmodem /usr/sbin/iaxmodem
    cp iaxmodem.init.fedora /etc/rc.d/init.d/iaxmodem
    sed -i 's/\/usr\/local\/sbin\/iaxmodem/\/usr\/sbin\/iaxmodem/g'  /etc/rc.d/init.d/iaxmodem
    chmod 0755 /etc/rc.d/init.d/iaxmodem
    chkconfig --add iaxmodem
    chkconfig iaxmodem on
    /etc/init.d/iaxmodem start
    
    
    
    #Configure Hylafax
    touch /var/spool/hylafax/etc/FaxDispatch
    echo "
    case "$DEVICE" in
       ttyIAX0) SENDTO=your@email.address; FILETYPE=pdf;; # all faxes received on ttyIAX0
       ttyIAX1) SENDTO=your@email.address; FILETYPE=pdf;; # all faxes received on ttyIAX1
       ttyIAX2) SENDTO=your@email.address; FILETYPE=pdf;; # all faxes received on ttyIAX2
       ttyIAX3) SENDTO=your@email.address; FILETYPE=pdf;; # all faxes received on ttyIAX3
    esac
    " > /var/spool/hylafax/etc/FaxDispatch
    
    chown uucp:uucp /var/spool/hylafax/etc/FaxDispatch
    
    # Set up Dial Plan
    
    echo "
    [custom-fax-iaxmodem]
    exten => s,1,Dial(IAX2/iax-fax0/\${EXTEN})
    exten => s,n,Dial(IAX2/iax-fax1/\${EXTEN})
    exten => s,n,Dial(IAX2/iax-fax2/\${EXTEN})
    exten => s,n,Dial(IAX2/iax-fax3/\${EXTEN})
    exten => s,n,Busy
    exten => s,n,Hangup
    " >> /etc/asterisk/extensions_custom.conf
    
    
    RESULT=`/usr/bin/mysql -uasteriskuser -p$MYSQLASTERISKUSERPASSWORD <<SQL
    
    use asterisk
    INSERT INTO custom_destinations 
    	(custom_dest, description, notes)
    	VALUES ('custom-fax-iaxmodem,s,1', 'Fax (Hylafax)', '');
    quit
    SQL`
    
    
    faxsetup
    
    
    #Install Avantfax
    
    cd /usr/src
    tar zxfv $LOAD_LOC/avantfax.tar.gz
    cd avantfax-3.1.6
    ./rh-install.sh
    
    rm -rf /etc/httpd/conf.d/avantfax.conf
    
    
    service httpd restart
    
    asterisk -rx "module reload"
    
    #chmod -x install-fax.sh
    
    echo " "
    echo " "
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo "IAXModem/Hylafax/Avantfax installation complete"
    echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    echo " "
    echo "Avantfax is covered by its own security, the credentials are admin / password"
    echo "You will be prompted to change the root password, then you can add other users"
    echo " "
    echo "Point a DID at the custom destination, FAX (Hylafax) which has been created for"
    echo "you in FreePBX. Outbound faxing will go out via the normal trunks"
    echo " "
    echo "nv-faxdetect has not been added in this install, so DID cannot be shared between"
    echo "extensions and faxes"
    echo " "
    echo "A Hylafax webmin module has been placed in $LOAD_LOC/hylafax_mod-1.8.2.wbm.gz"
    echo "This is added via Webmin | Webmin Configuration | Webmin Modules | From Local File"
    echo " "
    echo "Please reboot as soon as you can to bring the fax online."
    
    
    
     
  2. DaveD

    Joined:
    Nov 12, 2007
    Messages:
    597
    Likes Received:
    0

Share This Page