Hylafax CAPI

#!/bin/bash

# preconfigure (do we need this?)
debconf-set-selections <<\EOF
postfix postfix/mailname string fax
postfix postfix/main_mailer_type select Internet Site
EOF

# install hylafax
apt-get install -y capi4hylafax hylafax-server

#
# default configuration
#
# configure capi
sed -i 's|#run_capi4hylafax=1|run_capi4hylafax=1|g' /etc/default/capi4hylafax
sed -i 's|USE_FAXGETTY=yes|USE_FAXGETTY=no|g' /etc/default/hylafax
echo "SendFaxCmd: /usr/bin/c2faxsend" >> /etc/hylafax/config

# optional
echo "@192.168.0.[0-9]+$" >> /etc/hylafax/hosts.hfaxd

# disable AutoCoverPage
sed -i 's|# AutoCoverPage:|AutoCoverPage:|g' /etc/hylafax/hyla.conf
# configure ghostscript
sed -i 's|/usr/share/ghostscript/8.62/lib|/usr/share/ghostscript/8.71/lib|g' /etc/hylafax/hyla.conf

sed -i 's|#UseISDNFaxService: 0|UseISDNFaxService: 1|g' /etc/hylafax/config.*
sed -i 's|# NumberPlusReplacer: "00"|NumberPlusReplacer: "00"|g' /etc/hylafax/config.*

# disable fax recive ?
sed -i 's|MaxConcurrentRecvs: 2|MaxConcurrentRecvs: 0|g' /etc/hylafax/config.faxCAPI

#
# optional
#
# configure german TagLineFormat
sed -i 's|From %%l\|%c\|Page %%P of %%T|%%l\|%%n\|%d.%m.%Y %T\|Seite %%p von %%t|g' /etc/hylafax/config.*
# OPTIONAL: outside line access (Amtsholung)
sed -i 's|NumberPrefix:|NumberPrefix: 0|g' /etc/hylafax/config.*

#
# user specific configuration
#
# configure LocalIdentifier
sed -i 's|"AVM CAPI4HylaFAX"|"INC GmbH"|g' /etc/hylafax/config.*
sed -i 's|+49.00.00000|+49.211.1236780256|g' /etc/hylafax/config.*
sed -i 's|#OutgoingMSN:|OutgoingMSN: 25|g' /etc/hylafax/config.*
sed -i 's|IncomingMSNs:|IncomingMSNs: "55667788"|g' /etc/hylafax/config.*

# create hylafax user
### faxadduser -p root root

# TODO: insserv: warning: script 'faxCAPI' missing LSB tags and overrides
cat <> /etc/init.d/faxCAPI
#! /bin/sh
ln -s /dev/capi20 /dev/faxCAPI
chown -R uucp:dialout /dev/faxCAPI
chmod 777 /dev/capi20
chmod 777 /dev/faxCAPI

/etc/init.d/hylafax restart
EOF

chmod 755 /etc/init.d/faxCAPI
update-rc.d faxCAPI defaults 14

# restart
/etc/init.d/faxCAPI

# restart hylafax
/etc/init.d/hylafax restart

# install hylafax to email
http://www.panticz.de/configure_Hylafax_to_Email

# test
sendfax -d PHONE_NO /usr/share/doc/transfig/fig2mpdf/sample-flat.pdf

# do we need this?
# 0 * * * * root /root/restartFax.sh

# allow other user to delete faxes
edit /etc/hylafax/config.*, set RecvFileMode: 0666

# Links
http://yajhfc.berlios.de/ - Hylafax Java client
http://www.hylafax.org/content/Desktop_Client_Software
http://winprinthylafax.sourceforge.net/