#! /bin/bash # $Id: faxrcvd.sh.in,v 1.49.4.1 2007/09/24 19:13:47 aidan Exp $ # # 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. # # # faxrcvd file devID commID error-msg # if [ $# -lt 4 ]; then echo "Usage: $0 file devID commID error-msg [ callID-1 [ callID-2 [ ... [ callID-n ] ] ] ]" exit 1 fi test -f etc/setup.cache || { SPOOL=`pwd` cat</dev/null 2>&1; then ERRORSTO=`$TTYCMD` else ERRORSTO=/dev/null fi # # Permit various types of attachment types: ps, tif, pdf # Note that non-ASCII filetypes require an encoder. # pdf requires tiff2ps and tiff2pdf # Multiple file types may be specified by separating them with # whitespace; in that case a separate attachment for each filetype # will be created. # FILETYPE=ps SENDTO= # # There is no good portable way to find out the fully qualified # domain name (FQDN) of the host or the TCP port for the hylafax # service so we fudge here. Folks may want to tailor this to # their needs; e.g. add a domain or use localhost so the loopback # interface is used. # HOSTNAME=`hostname` # XXX no good way to find FQDN PORT=4559 # XXX no good way to lookup service FILE="$1"; shift; DEVICE="$1"; shift; COMMID="$1"; shift; MSG="$1"; shift; COUNT=1 while [ $# -ge 1 ]; do # The eval has $1 set yet, and this forces a variable-to-variable # assignment, allowing us to not need to do escaping eval CALLID$COUNT='$1' export CALLID$COUNT shift COUNT=`expr $COUNT + 1` done CIDNUMBER="$CALLID1" CIDNAME="$CALLID2" FILENAME=`echo $FILE | $SED -e 's/\.tif//' -e 's/recvq\///'` SetupPrivateTmp parseFaxInfo $FILE MIMEBOUNDARY="NextPart$$" export FILE export COMMID export DEVICE export MSG export FROMADDR export HOSTNAME export PORT export SENDTO export TOADDR # # Apply customizations. All customizable variables should # be set to their non-customized defaults prior to this. # if [ -f etc/FaxDispatch ]; then . etc/FaxDispatch # NB: FaxDispatch sets SENDTO fi if [ -f etc/templates/$TEMPLATE/hook.sh ] then # Any hooks that the templates need . etc/templates/$TEMPLATE/hook.sh fi ## MailWithFAX ## Email the template,adding the attachments according ## to $FILETYPE to $SENDTO ## ## We use the common CreateMailMessage