#!/bin/sh #---------------------------------------------------------------------------- # new_fax # # Copyright (c) 2002-2004 Stefan Krister # Copyright (c) 2005 Frank Meyer # # Last Update: $Id$ # # Parameter: $1 - result code # $2 - number of sender # $3 - number of pages # $4 - file(s) # # 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. #---------------------------------------------------------------------------- # set -vx # # set file names and pathes # fax_spoolpath=/var/spool/fax/incoming fax_logfile=/var/spool/fax/log/fax-empfang-journal.txt fax_tmppath=/tmp # # set parameters # curr_date=`/bin/date +%d%m%Y%H%M%S` curr_longdate=`/bin/date +%d.%m.%Y` curr_longtime=`/bin/date +%H:%M:%S` filedate=`/bin/date +%Y-%m-%d-%H-%M-%S` # # read eisfax configuration # . /var/run/eisfax # # number of sender # # - delete leading spaces # - delete trailing spaces # - replace ' ', '_', '.' with '-' fax_sender=`echo "$2"|sed -e 's/ *//' -e 's/ *$//' -e 's/[ _\.]/-/g'` if [ "$fax_sender" = "" ] then fax_sender="unknown" fi # # number of pages # fax_pages="$3" # # fax size / resolution # shift 3 idx=1 fax_file=$1 RES=`basename $fax_file|sed 's/.\(.\).*/\1/'` if [ "$RES" = "n" ] then fax_stretch="-R 98" else fax_stretch="-R 196" fi # # file name # while [ $idx -le $fax_pages ] do shift fax_file=" $fax_file $1" idx=`expr $idx + 1` done # # convert multiple G3 files to one TIFF file # fax_pdffile="$fax_spoolpath/$filedate.$fax_pages.$fax_sender.pdf" /usr/bin/fax2tiff -M \ $fax_stretch \ $fax_file \ -o "$fax_tmppath/$$newfax.tiff" if [ "$EISFAX_RECEIVE_AUTOPRINT" == "yes" ] then # ein Postscriptfile draus machen /usr/bin/tiff2ps -a \ -1 \ -p \ $fax_tmppath/$$newfax.tiff \ -O $fax_tmppath/$$newfax.ps # ein fuer den Drucker passendes File draus machen /usr/local/bin/gs -sDEVICE=$EISFAX_RECEIVE_PRINTERDRIVER \ -sOutputFile=$fax_tmppath/$$newfax.prn \ -dBATCH \ -dNOPAUSE \ -q /usr/lib/mgetty+sendfax/margins.ps $fax_tmppath/$$newfax.ps # und ab zum Drucker /usr/bin/lpr -P$EISFAX_RECEIVE_PRINTERQUEUE $fax_tmppath/$$newfax.prn logger -is FAX gedruckt rm $fax_tmppath/$$newfax.prn rm $fax_tmppath/$$newfax.ps fi # # convert from TIFF to PDF # /usr/bin/fax2pdf $fax_tmppath/$$newfax.tiff $fax_pdffile if [ -f "$fax_pdffile" ] then # if [ "$EISFAX_DO_DEBUG" != "yes" ] # then # pdf file has been created - delete files rm $fax_file $fax_tmppath/$$newfax.tiff # fi chmod 666 $fax_pdffile fi # # write log entry # echo $curr_longdate \ $curr_longtime \ $fax_sender \ $fax_pages \ $curr_date.$fax_pages.$fax_sender.pdf >> $fax_logfile if [ "$EISFAX_RECEIVE_AUTOMAIL" = "yes" ] then # send fax as mail /usr/bin/faxrcvd-mail-pdf "$EISFAX_RECEIVE_AUTOMAIL_MAILADDR" \ "$fax_pdffile"|/usr/sbin/sendmail \ "$EISFAX_RECEIVE_AUTOMAIL_MAILADDR" fi exit 0