#! /bin/sh # $Id$ # # 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. # # 2004/02/28 Frank Brock # # The notify shell now behaves in a manner like faxrcvd. # It is now written in shell with a little embedded awk as needed. # # notify qfile why jobtime [nextTry] # # Return mail to the submitter of a job when notification is needed. # #exec 2>/public/faxnotify-trace$$.log #set -x if [ $# != 3 ] && [ $# != 4 ]; then echo "Usage: $0 qfile why jobtime [nextTry]" exit 1 fi test -f etc/setup.cache || { SPOOL=`pwd` cat</dev/null 2>&1; then ERRORSTO=`$TTYCMD` else ERRORSTO=/dev/null fi adjustNotifyFaxMaster() { # Determine what NOTIFY_FAXMASTER should be set to based # on the current value of NOTIFY_FAXMASTER and on other # attributes set about this notification. # NOTIFY_FAXMASTER can be set to # yes - send everything # no - send nothing # errors - send only failed type faxes that are not from busy, no answer or no carrier # always - send everything # never - send nothing # # known $WHY values we can test to set NOTIFY_FAXMASTER are # "done" "failed" "rejected" "blocked" "requeued" "removed" "killed" "timedout" # "format_failed" "no_formatter" "poll_rejected" "poll_no_document" "poll_failed" case $NOTIFY_FAXMASTER in never|no) NOTIFY_FAXMASTER=no;; always|yes) NOTIFY_FAXMASTER=yes;; errors) case $WHY in timedout|rejected|format_failed|no_formatter|poll_rejected|poll_no_document) NOTIFY_FAXMASTER=yes;; "done"|blocked|removed|killed) NOTIFY_FAXMASTER=no;; *) if (match "$faxstatus" "Busy signal") || (match "$faxstatus" "No answer") || (match "$faxstatus" "No carrier"); then NOTIFY_FAXMASTER=no else NOTIFY_FAXMASTER=yes fi;; esac;; *) NOTIFY_FAXMASTER=no;; esac } setCustomValues() { # # Apply customizations. All customizable variables should # be set to their non-customized defaults prior to this. # if [ -f etc/FaxNotify ]; then # source notify preferecnes . etc/FaxNotify fi # hb beginn 2006-08-13 SENDADR= # hb end 2006-08-13 # # Language settings... # . bin/dictionary . bin/dictionary-local if [ -f etc/FaxDictionary ]; then . etc/FaxDictionary fi setItemSize } fileType() # determine the type of file passed using the unix 'file' command # with the '-i' option (mime type output) { FILENAME=$1 if [ -f "$FILENAME" ] ; then FILETYPE=`file $FILENAME` if (match "$FILETYPE" "postscript") ; then echo "PostScript" elif (match "$FILETYPE" "tiff") ; then echo "TIFF" elif (match "$FILETYPE" "pdf") ; then echo "PDF" else echo "$DICTUNKNOWNDOCTYPE" fi else echo "$DICTNOFILEEXISTS" fi } returnFaxImage() # output a mime encoded set of file attachments with mime headers # for each file listed in the files_XX set, make sure that it is # a valid, non zero file. Then test the file format of the source # file we are encoding that is is a known file type that we can # convert from. Out put to standard out the appropriate mime header. # Then based on the argument passed to this function, # convert the source file to the file format given as the argument. # finally, encode this converted file and put it out on std out. # Supported values of RETURNFORMAT are "tif","pdf", and "ps" # A ReturnFomat=original reutns the file in its original format. # Supported file formats of the source are "tiff", "pdf" and "ps" { RETURNFORMAT=$1 if [ $nfiles -gt 0 ] ; then for i in `local_seq 1 $nfiles`; do name="files_$i" eval filename=`echo "$"$name` if [ -s $filename ] ; then # file is > 0 size type="filetype_$i" eval FROMFMT=`echo "$"$type` # # Because Ghostscript accepts PDF identically to PostScript # and because HylaFAX has historically handled PDF named as # "postscript" we have to double-check the PostScript filetype. # if [ "$FROMFMT" = "PostScript" ]; then if [ "`fileType $filename`" != "PostScript" ]; then FROMFMT=PDF fi fi case "$FROMFMT" in "PostScript" | "TIFF" | "PDF" ) # test we know the source format if [ "$RETURNFORMAT" = "tif" ] ; then # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.tif" ENCODEDFILENAME="$DATUM-$number-$i.tif" # hb end 2005-05-17 putMimeImageTIFHeader "$ENCODEDFILENAME" putTifEncodedImage "$filename" "$FROMFMT" elif [ "$RETURNFORMAT" = "pdf" ] ; then # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.pdf" ENCODEDFILENAME="$DATUM-$number-$i.pdf" # hb end 2005-05-17 putMimeAppPDFHeader "$ENCODEDFILENAME" putPdfEncodedImage "$filename" "$FROMFMT" elif [ "$RETURNFORMAT" = "ps" ] ; then # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.ps" ENCODEDFILENAME="$DATUM-$number-$i.ps" # hb end 2005-05-17 putMimeAppPSHeader "$ENCODEDFILENAME" putPsEncodedImage "$filename" "$FROMFMT" elif [ "$RETURNFORMAT" = "original" ] ; then case "$FROMFMT" in "TIFF") # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.tif" ENCODEDFILENAME="$DATUM-$number-$i.tif" # hb end 2006-01-07 putMimeImageTIFHeader "$ENCODEDFILENAME" putTifEncodedImage "$filename" "$FROMFMT" ;; "PostScript") # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.ps" ENCODEDFILENAME="$DATUM-$number-$i.ps" # hb end 2006-01-07 putMimeAppPSHeader "$ENCODEDFILENAME" putPsEncodedImage "$filename" "$FROMFMT" ;; "PDF") # hb begin 2005-05-17 # ENCODEDFILENAME="$number-$i.pdf" ENCODEDFILENAME="$DATUM-$number-$i.pdf" # hb end 2006-01-07 putMimeAppPDFHeader "$ENCODEDFILENAME" putPdfEncodedImage "$filename" "$FROMFMT" ;; esac fi ;; esac fi # file[i] exists done # for each nfiles fi # nfiles > 0 } putPdfEncodedImage() # Convert the source file from the CONVERTFROM type into a pdf file and # then do a mimeEndode of the file { SOURCEFILE=$1 CONVERTFROM=$2 OUTFILE="tmp/conv2pdf$$.out" ; if [ "$CONVERTFROM" = "PDF" ] ; then encode "$SOURCEFILE" return # all done here elif [ "$CONVERTFROM" = "TIFF" ] ; then CONVERTCMD="$TIFF2PDF -o $OUTFILE $SOURCEFILE" elif [ "$CONVERTFROM" = "PostScript" ] ; then CONVERTCMD="$PS2PDF $SOURCEFILE $OUTFILE" else return # unknow convert from format fi $CONVERTCMD > $ERRORSTO 2>&1 encode "$OUTFILE" $RM -f $OUTFILE > $ERRORSTO 2>&1 } putPsEncodedImage() # Convert the source file from the CONVERTFROM type into a ps file and # then do a mimeEndode of the file { SOURCEFILE=$1 CONVERTFROM=$2 OUTFILE="tmp/conv2ps$$.out" ; if [ "$CONVERTFROM" = "PostScript" ] ; then encode "$SOURCEFILE" return # all done here elif [ "$CONVERTFROM" = "TIFF" ] ; then # tiff2ps -a for all pages, CONVERTCMD="$TIFF2PS -a $SOURCEFILE > $OUTFILE" elif [ "$CONVERTFROM" = "PDF" ] ; then CONVERTCMD="$PDF2PS $SOURCEFILE $OUTFILE" else return # unknow convert from format fi $CONVERTCMD > $ERRORSTO 2>&1 encode "$OUTFILE" $RM -f $OUTFILE > $ERRORSTO 2>&1 } putTifEncodedImage() # Convert the source file from the CONVERTFROM type into a tif file and # then do a mimeEndode of the file { SOURCEFILE=$1 CONVERTFROM=$2 OUTFILE="tmp/conv2tif$$.out" ; if [ $CONVERTFROM = "TIFF" ] ; then encode "$SOURCEFILE" return # all done here elif [ $CONVERTFROM = "PDF" ] ; then CONVERTCMD="$PDF2FAX -r $resolution -o $OUTFILE $SOURCEFILE" elif [ $CONVERTFROM = "PostScript" ] ; then CONVERTCMD="$PS2FAX -r $resolution -o $OUTFILE $SOURCEFILE" else return # unknow convert from format fi $CONVERTCMD > $ERRORSTO 2>&1 encode "$OUTFILE" $RM -f $OUTFILE > $ERRORSTO 2>&1 } putMimeSetup() # write out the setup portions of the mime encoded message # # NOTES ABOUT MIME that I have figured out thus far since I am not a mime expert in any way. # The mimeboundary is defined in the setup of the email. # Mimeboundary, as defined, with a leading "--" must be used to seperate mime sections. # The mime email must be terminated by a mimeboundary with a leading AND trailing "--" # A MimeBoundary must immediately preceed the mime content definition section for each # of the mime sections. No blank lines between the mimeboundary and the content definition. # I think a blank line in front of the mimeboundary is required. # So, the code hear is organized such that all functions putting out a mime contect section # are respnosible for putting in their own leading mimeboundary. But they are NOT to put in # any mime boundary trailers. # The last thing of the action section is to put in terminating mime boundary. # { echo "MIME-Version: 1.0" echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\"" echo "Content-Transfer-Encoding: 7bit" } putMimeTextHeader() # write out the beginning mime boundary for plain/text part { echo "" echo "This is a multi-part message in MIME format." echo "" echo "--$MIMEBOUNDARY" echo "Content-Type: text/plain; charset=$CHARSET" echo "Content-Transfer-Encoding: quoted-printable" echo "" } putMimeAppPDFHeader() # filename passed should already include the proper .pdf extension # write out the beginning mime boundary for the pdf file application part # filename is just the name of the file for mime header encoding and is what is # shown as the name of the attahced file. { echo "" echo "--$MIMEBOUNDARY" echo "Content-Type: application/pdf; name=\"$1\"" echo "Content-Description: FAX document" echo "Content-Transfer-Encoding: $ENCODING" echo "Content-Disposition: attachment; filename=\"$1\"" echo "" } putMimeAppPSHeader() # filename passed should already include the proper .ps extension # write out the beginning mime boundary for the ps file application part # filename is just the name of the file for mime header encoding and is what is # shown as the name of the attahced file. { echo "" echo "--$MIMEBOUNDARY" echo "Content-Type: application/postscript; name=\"$1\"" echo "Content-Description: FAX document" echo "Content-Transfer-Encoding: $ENCODING" echo "Content-Disposition: attachment; filename=\"$1\"" echo "" } putMimeImageTIFHeader() # filename passed should already include the proper .tif extension # write out the beginning mime boundary for the tif file image part # filename is just the name of the file for mime header encoding and is what is # shown as the name of the attahced file. { echo "" echo "--$MIMEBOUNDARY" echo "Content-Type: image/tiff; name=\"$1\"" echo "Content-Description: FAX document" echo "Content-Transfer-Encoding: $ENCODING" echo "Content-Disposition: attachment; filename=\"$1\"" echo "" } printItem() { FMT="`echo %$ITEMSIZE\s: $1`" TAG="$2" VALUE="$3" printf " $FMT\n" "$TAG" "$VALUE" } printBanner() { echo "" echo " ---- $1 ----" echo "" } match() # look for substring in fullsting. substring can be a regular expression or plain string # if the substring is found anywhere in the full string, true(0) is returned. { FULLSTR="$1" SUBSTR="$2" echo "$FULLSTR" | $GREP -i "$SUBSTR" > /dev/null 2>&1 if [ $? -eq 0 ] ; then return 0 else return 1 fi } # # Construct a return-to-sender message. # returnToSender() { printBanner "Unsent job status" printItem "%s" "$DICTDESTINATION" "$number" printItem "%s" "$DICTJOBID" "$jobid" printItem "%s" "$DICTGROUPID" "$groupid" printItem "%s" "$DICTSENDER" "$sender" printItem "%s" "$DICTMAILADDR" "$mailaddr" if [ -n "$commid" ] ; then printItem "%s" "$DICTCOMMID" "$commid" fi if [ "$modem" != "any" -a "$RETURNTECHINFO" = "yes" ] ; then printItem "%s" "$DICTMODEM" "$modem" fi printItem "%s" "$DICTSUBMITTEDFROM" "$client" if [ "$jobtype" = "facsimile" -a "$RETURNTECHINFO" = "yes" ] ; then printItem "%u (mm)" "$DICTPAGEWIDTH" "$pagewidth" printItem "%.0f (mm)" "$DICTPAGELENGTH" "$pagelength" printItem "%.0f (lpi)" "$DICTRES" "$resolution" fi if [ -z "$faxstatus" ] ; then faxstatus=" ($DICTNOTHINGAVAIL)" ; fi # we need to use the %b (instead of the %s) so the embedded escape characters will # be interpreted. printItem "%b" "$DICTSTATUS" "$faxstatus" printItem "%u ($DICTREMOTEEXCHANGES)" "$DICTDIALOGS" "$tottries" printItem "%u ($DICTFAILEDCALLS)" "$DICTDIALS" "$ndials" printItem "%u ($DICTTOTALCALLS)" "$DICTCALLS" "$totdials" if [ "$jobtype" = "facsimile" ] ; then printItem "%u ($DICTPAGESTRANSMITTED)" "$DICTPAGES" "$npages" printItem "%u ($DICTTOTALPAGES)" "$DICTTOTPAGES" "$totpages" printItem "%u ($DICTATTEMPTSPAGE)" "$DICTATTEMPS" "$ntries" printItem "%u ($DICTDIRNEXTPAGE)" "$DICTDIRNUM" "$dirnum" if [ $nfiles -gt 0 -a "$RETURNTECHINFO" = "yes" ] ; then printBanner "$DICTDOCSSUBMITTED" eval echo "$DICTDOCSTEXT1" eval echo "$DICTDOCSTEXT2" eval echo "$DICTDOCSTEXT3" eval echo "$DICTDOCSTEXT4" echo "" printf "%-20s %8s %s\n" "$DICTFILENAME" "$DICTSIZE" "$DICTTYPE" for i in `local_seq 1 $nfiles`; do name="files_$i" eval filename=`echo "$"$name` if [ -f $filename ] ; then set - `wc -c "$filename"` FILESIZE=$1 type="filetype_$i" eval filetype=`echo "$"$type` # # Because Ghostscript accepts PDF identically to PostScript # and because HylaFAX has historically handled PDF named as # "postscript" we have to double-check the PostScript filetype. # if [ "$filetype" = "PostScript" ]; then if [ "`fileType $filename`" != "PostScript" ]; then filetype=PDF fi fi printf "%-20s %8d %s\n" "$filename" "$FILESIZE" "$filetype" fi done fi elif [ "$jobtype" = "pager" ] ; then if [ $npins -ne 0 ] ; then printBanner "$DICTUNSENTPAGES" for i in `local_seq 1 $npins`; do name="files_$i" eval pin=`echo "$"$name` printf "%15s\n" "$DICTPIN" $pin done fi if [ $nfiles -ne 0 -a -s $files_0 ] ; then printBanner "$DICTMESSAGETEXT" cat $files_0 fi fi } returnTranscript() { if [ "$RETURNTRANSCRIPT" = "yes" ] ; then printBanner "$DICTLOGFOLLOWS2" COMFILE="log/c$commid" if [ -f "$COMFILE" ] ; then # dump the comfile to output except for '-- data' lines cat $COMFILE | $GREP -v "\-\- data" else printf "$DICTNOLOGAVAIL" if [ -n "$commid" ] ; then # non 0 len commid value printf "($DICTCOMMID c$commid)" fi echo "." fi fi } printStatus() { if [ -z "$1" ] ; then # 0 string len echo "<$DICTNOREASON>" else # we need to change the '\n' in the strings to real newlines echo "$1" | sed -e 's/\\n/\n/g' fi } putHeaders() { putMimeSetup echo "To: ${!SENDADR}" echo "From: $FROMADDR" echo "Subject: $1" putMimeTextHeader THISJOBTYPE=`eval echo "$"DICT$jobtype` eval printf \"$DICTYOURJOBTO\" } ########## ## MAIN ########## # exports used for debug tracing #export -f returnTranscript #export -f putMimeAppPDFHeader #export -f putMimeImageTIFHeader #export -f printItem #export -f putTifEncodedImage #export -f putMimeSetup #export -f printStatus #export -f putHeaders #export -f returnFaxImage #export -f putPdfEncodedImage #export -f putMimeTextHeader #export -f printBanner #export -f returnToSender #export -f parseQfile #export -f match # sh -x # we parse the q file first in case any of the varialbe setting # operations may want to know about the details of the fax parseQfile #process the FaxNotify script after parse q file in case the admin wants to # set any values based on what is in the q file setCustomValues # adjust faxmaster notify based on some rules and what is found # possibly in the q file. adjustNotifyFaxMaster # beginn hb 2006-04-04 chance for printng and copy if [ -f ${QFILE} ] then if [ -n "${SENDADR}" ] then ( if [ -z "$jobtag" ] ; then THISJOBTYPE=`eval echo "$"DICT$jobtype` jobtag="`eval echo $DICTJOB`" fi if [ "$doneop" = "default" ] ; then doneop="remove" fi if [ "$jobtype" = "pager" ] ; then number=$pagernum fi DESTINATION="$receiver" if [ -n "$receiver" ] && [ -n "$company" ]; then DESTINATION="$receiver $DICTAT " fi DESTINATION="$DESTINATION$company" if [ -n "$DESTINATION" ]; then DESTINATION="$DESTINATION ($number)" else DESTINATION="$number" fi if [ "$WHY" = "done" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTCOMPLETED" echo "$DICTCOMPLETEDSUCCESSFULLY"; echo ""; if [ "$jobtype" = "facsimile" ] ; then printItem "%u" "$DICTPAGES" "$npages" printItem "%s" "$DICTRECEIVER" "$csi" if [ "$RETURNTECHINFO" = "yes" ] ; then if [ "$resolution" = "196" ] ; then printItem "%s" "$DICTQUALITY" "$DICTFINE" else printItem "%s" "$DICTQUALITY" "$DICTNORMAL" fi printItem "%u (mm)" "$DICTPAGEWIDTH" "$pagewidth" printItem "%.0f (mm)" "$DICTPAGELENGTH" "$pagelength" printItem "%s" "$DICTSIGNALRATE" "$signalrate" printItem "%s" "$DICTDATAFORMAT" "$dataformat" # hb beginn 2005-09-12 printItem "%s" "${DICTSENDDATETIME}" "`date +'%Y-%m-%d %H:%M:%S'`" # hb end 2005-09-12 printItem "%s" "$DICTREMOTEEQUIPMENT" "$equipment" printItem "%s" "$DICTREMOTESTATION" "$station" fi fi if [ "$RETURNTECHINFO" = "yes" ] ; then if [ "$tottries" != "1" ] ; then printItem "%s ($DICTREMOTEEXCHANGES)" "$DICTDIALOGS" "$tottries" fi if [ "$totdials" != "1" ] ; then printItem "%s ($DICTTOTALCALLS)" "$DICTCALLS" "$totdials" fi if [ "$modem" != "any" ] ; then printItem "%s" "$DICTMODEM" "$modem" fi printItem "%s" "$DICTSUBMITTEDFROM" "$client" printItem "%s" "$DICTJOBID" "$jobid" printItem "%s" "$DICTGROUPID" "$groupid" printItem "%s" "$DICTCOMMID" "c$commid" printf "\n$DICTPROCESSINGTIME %s.\n" "$JTIME" fi if [ -n "$faxstatus" -a "$RETURNTRANSCRIPT" = "yes" ] ; then # use -e in echo to interpret escape characters in faxstatus echo "$DICTADDITIONALINFO" printStatus " $faxstatus" returnTranscript fi if [ -n "$RETURNFILETYPE" ] ; then returnFaxImage "$RETURNFILETYPE" fi elif [ "$WHY" = "failed" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" printf " $DICTFAILEDBECAUSE\n " printStatus "$faxstatus" returnTranscript returnToSender if [ -n "$RETURNFILETYPE" ] ; then returnFaxImage "$RETURNFILETYPE" fi elif [ "$WHY" = "rejected" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" printf " $REJECTEDBECAUSE\n " printStatus "$faxstatus" returnToSender if [ -n "$RETURNFILETYPE" ] ; then returnFaxImage "$RETURNFILETYPE" fi elif [ "$WHY" = "blocked" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTBLOCKED" printf " $DICTDELAYEDBECAUSE\n " printStatus "$faxstatus" echo "" echo "$DICTASSOONASPOSSIBLE" elif [ "$WHY" = "requeued" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTREQUEUED" printf " $DICTWASNOTSENT\n " printStatus "$faxstatus" echo "" echo "$DICTWILLBERETRIED $NEXT." returnTranscript elif [ "$WHY" = "removed" ] || [ "$WHY" = "killed" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTREMOVEDFROMQUEUE" echo " $DICTWASDELETED" if [ "$WHY" = "killed" ] ; then returnToSender fi if [ -n "$RETURNFILETYPE" ] ; then returnFaxImage "$RETURNFILETYPE" fi elif [ "$WHY" = "timedout" ]; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" echo " $DICTTIMEDOUT" returnToSender if [ -n "$RETURNFILETYPE" ] ; then returnFaxImage "$RETURNFILETYPE" fi elif [ "$WHY" = "format_failed" ] ; then putHeaders "$jobtag to $DESTINATION $DICTFAILED" echo " $DICTCONVERSION1" echo "$DICTCONVERSION2" echo "" printStatus "$faxstatus" echo "" echo "$DICTCONVERSION3" returnToSender elif [ "$WHY" = "no_formatter" ] ; then putHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" echo " $DICTNOFORMATTER1" echo "$DICTNOFORMATTER2" returnToSender elif (match "$WHY" "poll_*") ; then putHeaders "$DICTNOTICEABOUT $jobtag" printf "$DICTPOLLINGFAILED" if [ "$WHY" = "poll_rejected" ] ; then echo "$DICTREMOTEREJECTED" elif [ "$WHY" = "poll_no_document" ] ; then echo "$DICTNODOCTOPOLL" elif [ "$WHY" = "poll_failed" ] ; then echo "$DICTUNSPECIFIEDPROBLEM" fi echo ""; printf "$DICTPROCESSINGTIME %s.\n" "$JTIME" returnTranscript else putHeaders "$DICTNOTICEABOUT $jobtag" echo " $DICTUNKNOWNREASON1" echo "$DICTUNKNOWNREASON2" echo "$DICTUNKNOWNREASON3" echo "" echo "why: $WHY" echo "jobTime: $JTIME" echo "nextTry: $NEXT" echo "" echo "$DICTUNKNOWNREASON4" returnTranscript returnToSender fi # put out a terminating MIME boundary echo "" echo "--$MIMEBOUNDARY--" ) 2>$ERRORSTO | $SENDMAIL -f$FROMADDR -oi -t # end ${SENDTO} fi # beginn hb 2006-04-09 putPrintHeaders() { echo echo "EisFAX Sendebericht" echo echo echo "$1" echo THISJOBTYPE=`eval echo "$"DICT$jobtype` eval printf \"$DICTYOURJOBTO\" } if [ -n "${PRINTTO}" -o -n "${COPYTO}" ] then ( if [ -z "$jobtag" ] then THISJOBTYPE=`eval echo "$"DICT$jobtype` jobtag="`eval echo $DICTJOB`" fi if [ "$doneop" = "default" ] then doneop="remove" fi if [ "$jobtype" = "pager" ] then number=$pagernum fi DESTINATION="$receiver" if [ -n "$receiver" ] && [ -n "$company" ] then DESTINATION="$receiver $DICTAT " fi DESTINATION="$DESTINATION$company" if [ -n "$DESTINATION" ] then DESTINATION="$DESTINATION ($number)" else DESTINATION="$number" fi if [ "$WHY" = "done" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTCOMPLETED" echo "$DICTCOMPLETEDSUCCESSFULLY"; echo ""; if [ "$jobtype" = "facsimile" ] then printItem "%u" "$DICTPAGES" "$npages" printItem "%s" "$DICTRECEIVER" "$csi" if [ "$RETURNTECHINFO" = "yes" ] then if [ "$resolution" = "196" ] then printItem "%s" "$DICTQUALITY" "$DICTFINE" else printItem "%s" "$DICTQUALITY" "$DICTNORMAL" fi printItem "%u (mm)" "$DICTPAGEWIDTH" "$pagewidth" printItem "%.0f (mm)" "$DICTPAGELENGTH" "$pagelength" printItem "%s" "$DICTSIGNALRATE" "$signalrate" printItem "%s" "$DICTDATAFORMAT" "$dataformat" # hb beginn 2005-09-12 printItem "%s" "${DICTSENDDATETIME}" "`date +'%Y-%m-%d %H:%M:%S'`" # hb end 2005-09-12 printItem "%s" "$DICTREMOTEEQUIPMENT" "$equipment" printItem "%s" "$DICTREMOTESTATION" "$station" fi # end ["$jobtype" = "facsimile"] fi if [ "$RETURNTECHINFO" = "yes" ] then if [ "$tottries" != "1" ] then printItem "%s ($DICTREMOTEEXCHANGES)" "$DICTDIALOGS" "$tottries" fi if [ "$totdials" != "1" ] then printItem "%s ($DICTTOTALCALLS)" "$DICTCALLS" "$totdials" fi if [ "$modem" != "any" ] then printItem "%s" "$DICTMODEM" "$modem" fi printItem "%s" "$DICTSUBMITTEDFROM" "$client" printItem "%s" "$DICTSENDER" "$sender" printItem "%s" "$DICTJOBID" "$jobid" printItem "%s" "$DICTGROUPID" "$groupid" printItem "%s" "$DICTCOMMID" "c$commid" printf "\n$DICTPROCESSINGTIME %s.\n" "$JTIME" fi if [ -n "$faxstatus" -a "$RETURNTRANSCRIPT" = "yes" ] then # use -e in echo to interpret escape characters in faxstatus echo "$DICTADDITIONALINFO" printStatus " $faxstatus" returnTranscript fi elif [ "$WHY" = "failed" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" printf " $DICTFAILEDBECAUSE\n " printStatus "$faxstatus" returnTranscript returnToSender elif [ "$WHY" = "rejected" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" printf " $REJECTEDBECAUSE\n " printStatus "$faxstatus" returnToSender elif [ "$WHY" = "blocked" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTBLOCKED" printf " $DICTDELAYEDBECAUSE\n " printStatus "$faxstatus" echo "" echo "$DICTASSOONASPOSSIBLE" elif [ "$WHY" = "requeued" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTREQUEUED" printf " $DICTWASNOTSENT\n " printStatus "$faxstatus" echo "" echo "$DICTWILLBERETRIED $NEXT." returnTranscript elif [ "$WHY" = "removed" ] || [ "$WHY" = "killed" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTREMOVEDFROMQUEUE" echo " $DICTWASDELETED" if [ "$WHY" = "killed" ] then returnToSender fi elif [ "$WHY" = "timedout" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" echo " $DICTTIMEDOUT" returnToSender elif [ "$WHY" = "format_failed" ] then putPrintHeaders "$jobtag to $DESTINATION $DICTFAILED" echo " $DICTCONVERSION1" echo "$DICTCONVERSION2" echo "" printStatus "$faxstatus" echo "" echo "$DICTCONVERSION3" returnToSender elif [ "$WHY" = "no_formatter" ] then putPrintHeaders "$jobtag $DICTTO $DESTINATION $DICTFAILED" echo " $DICTNOFORMATTER1" echo "$DICTNOFORMATTER2" returnToSender elif (match "$WHY" "poll_*") then putPrintHeaders "$DICTNOTICEABOUT $jobtag" printf "$DICTPOLLINGFAILED" if [ "$WHY" = "poll_rejected" ] then echo "$DICTREMOTEREJECTED" elif [ "$WHY" = "poll_no_document" ] then echo "$DICTNODOCTOPOLL" elif [ "$WHY" = "poll_failed" ] then echo "$DICTUNSPECIFIEDPROBLEM" fi echo ""; printf "$DICTPROCESSINGTIME %s.\n" "$JTIME" returnTranscript else putPrintHeaders "$DICTNOTICEABOUT $jobtag" echo " $DICTUNKNOWNREASON1" echo "$DICTUNKNOWNREASON2" echo "$DICTUNKNOWNREASON3" echo "" echo "why: $WHY" echo "jobTime: $JTIME" echo "nextTry: $NEXT" echo "" echo "$DICTUNKNOWNREASON4" returnTranscript returnToSender fi echo "" # TechInfo create ) | $A2PS -o /tmp/$$notifyfax.ps -1 \ -R \ -f 11 \ -M a4 \ -B \ --header=%a \ --borders=no \ -s 1 fi # beginn hb 2006-04-02 # beginn ${PRINTTO} if [ -n "${PRINTTO}" ] then ( echo "${AUTOPRINT_TXT} ${files_1}" echo "${AUTOPRINT_TXT} printer ${PRINTTO}" ) >> ${AUTOPRINT_LOG} if [ -z "${PRINTDRIVER}" ] then ( echo "${AUTOPRINT_TXT} ${PRINTTO} is a postscript printer" ) >> ${AUTOPRINT_LOG} # ab zum Drucker if [ -n "${PRINTINFO}" ] then # TechInfo and ${files_1} ${BIN}/lpr -P ${PRINTTO} /tmp/$$notifyfax.ps ${files_1} >> ${AUTOPRINT_LOG} 2>&1 else # ${files_1} only ${BIN}/lpr -P ${PRINTTO} ${files_1} >> ${AUTOPRINT_LOG} 2>&1 fi if [ ${?} -eq 0 ] then ( echo "${AUTOPRINT_TXT} printed ${files_1} on ${PRINTTO} ..." ) >>${AUTOPRINT_LOG} ${BIN}/logger -is FAX printed on ${PRINTTO} fi # fuer Ghostscript printing aufbereiten else ( echo "${AUTOPRINT_TXT} ${PRINTTO} is a ghostscript printer" echo "${AUTOPRINT_TXT} printer driver ${PRINTDRIVER}" ) >> ${AUTOPRINT_LOG} # fuer den Drucker aufbereiten if [ -n "${PRINTINFO}" ] then # TechInfo and ${files_1} ${GSRIP} -q \ -sDEVICE=${PRINTDRIVER} \ -dNOPAUSE \ -sPAPERSIZE=a4 \ -sOutputFile=\|"${BIN}/lpr -P ${PRINTTO}" \ /tmp/$$notifyfax.ps ${files_1} \ -c quit \ >> ${AUTOPRINT_LOG} 2>&1 else # ${files-1} only ${GSRIP} -q \ -sDEVICE=${PRINTDRIVER} \ -dNOPAUSE \ -sPAPERSIZE=a4 \ -sOutputFile=\|"${BIN}/lpr -P ${PRINTTO}" \ ${files_1} \ -c quit \ >> ${AUTOPRINT_LOG} 2>&1 fi if [ ${?} -eq 0 ] then ( echo "${AUTOPRINT_TXT} printed ${files_1} on ${PRINTTO} ..." ) >> ${AUTOPRINT_LOG} ${BIN}/logger -is FAX printed on ${PRINTTO} else ( echo "${AUTOPRINT_TXT} cannot print ${files_1} on ${PRINTTO} ..." ) >> ${AUTOPRINT_LOG} fi # end if [ -z ${PRINTDRIVER} ] fi # end ${PRINTTO} fi # end hb 2006-04-02 # hb beginn 2006-04-06 if [ -n "${COPYTO}" ] then # TechInfo and ${files_1} merge as PDF sudo ${GSRIP} -q \ -sDEVICE=pdfwrite \ -dNOPAUSE \ -dCompatibilityLevel=1.3 \ -sPAPERSIZE=a4 \ -sOutputFile=${COPYTO}/$DATUM-$number-$i.pdf \ /tmp/$$notifyfax.ps ${files_1} \ -c quit sudo /bin/chown ${COPYFOR}:users ${COPYTO}/$DATUM-$number-$i.pdf sudo /bin/chmod ${COPYMOD} ${COPYTO}/$DATUM-$number-$i.pdf fi # Reste entsorgen ${RM} /tmp/$$notifyfax.ps # hb end 2006-04-17 # end ${QFILE} fi if [ "$NOTIFY_FAXMASTER" = "yes" ]; then # make sure that FAXMASTER gets all information in email by forcing some RETURN values # and then reset them later origRETURNTRANSCRIPT=$RETURNTRANSCRIPT origRETURNTECHINFO=$RETURNTECHINFO RETURNTRANSCRIPT="yes" RETURNTECHINFO="yes" ( if [ -z "$jobtag" ] ; then jobtag="$jobtype job $jobid" fi echo "To: $TOADDR" echo "From: $FROMADDR" echo "Subject: $jobtag to $number $WHY" echo returnTranscript returnToSender ) 2>$ERRORSTO | $SENDMAIL -f$FROMADDR -oi -t RETURNTRANSCRIPT=$origRETURNTRANSCRIPT RETURNTECHINFO=$origRETURNTECHINFO fi