#!/bin/sh #---------------------------------------------------------------------------- # faxsend-local # # Creation: 2007-08-04 hb # Last Update: $Id$ # # Copyright (c) 2007-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gmx(dot)net # # 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 script is a wrapper to call the correct faxsend # program, depending of the modem type #exec 2> /tmp/faxsend-trace$$.log #set -x PARA=${*} SENDFAX=/usr/sbin/faxsend MODEM_FILE=/var/lib/eisfax/print-modem MODEM_FILE_ISDN=/var/lib/eisfax/print-modem-isdn MODEM_FILE_FRITZBOX=/var/lib/eisfax/print-modem-fritzbox m_found="no" while [ ${#} -gt 0 ] do case ${1} in "-m") m_found="yes" ;; capifax) if [ "${m_found}" = "yes" ] then capifaxpara=${PARA} modem_used=${1} modem='capifax' # set modemused in the qfile set_capi_fax_tagline () { while [ ${#} -gt 0 ] do case ${1} in sendq/q*) send_modem=$(grep "^modem:" ${1} | sed "s#^modem:##") sed -i "s#^modemused:.*\$#modemused:${modem_used}#" ${1} fb_number="$(grep "^number:" ${1} | sed "s#^number:##")" fb_file="$(grep "^fax" ${1} | cut -d ':' -f4)" fb_send=${1} line_info="$(grep "^${send_modem}:" ${MODEM_FILE_FRITZBOX})" old_IFS=${IFS} IFS=":" set -- ${line_info} IFS=${old_IFS} fb_header="${2}" fb_ident="${3}" fb_contr="${4}" fb_msn="${5}" fb_loglevel="${6}" ;; esac shift done } set_capi_fax_tagline ${capifaxpara} SENDFAX=/usr/bin/capifax fi m_found="no" ;; faxCAPI*) if [ "${m_found}" = "yes" ] then faxcapipara=${PARA} modem_used=${1} modem='faxcapi' # set modemused in the qfile, c4h dosn't set_fax_capi_tagline () { while [ ${#} -gt 0 ] do case ${1} in sendq/q*) send_modem=$(grep "^modem:" ${1} | sed "s#^modem:##") send_identifier="-c localidentifier:\"$(grep "^${send_modem}:" ${MODEM_FILE_ISDN} | cut -d: -f2)\"" sed -i "s#^modemused:.*\$#modemused:${modem_used}#" ${1} ;; esac shift done } set_fax_capi_tagline ${faxcapipara} SENDFAX=/usr/bin/c2faxsend fi m_found="no" ;; tty*) if [ "${m_found}" = "yes" ] then ttySpara=${PARA} modem_used=${1} modem='tty' # set tagline for multiple faxheader set_ttyS_tagline () { while [ ${#} -gt 0 ] do case ${1} in sendq/q*) send_modem=$(grep "^modem:" ${1} | sed "s#^modem:##") send_identifier="-c localidentifier:\"`grep "^${send_modem}:" ${MODEM_FILE} | cut -d: -f2`\"" send_tagline="-c taglineformat:\"$(grep "^${send_modem}:" ${MODEM_FILE} | cut -d: -f3)\"" ;; esac shift done } set_ttyS_tagline ${ttySpara} SENDFAX=/usr/sbin/faxsend fi m_found="no" ;; *) m_found="no" ;; esac shift done case ${modem} in tty) ${SENDFAX} "${send_identifier}" "${send_tagline}" ${PARA} ;; faxcapi) ${SENDFAX} "${send_identifier}" ${PARA} ;; capifax) ${SENDFAX} -send ${fb_file} ${fb_contr} ${fb_msn} ${fb_number} -header "${fb_header}" -ident "${fb_ident}" ret=${?} if [ ${ret} -eq 0 ] then sed -i 's#^returned:.*$#returned:2#' ${fb_send} elif [ ${ret} -eq 2 ] then sed -i 's#^returned:.*$#returned:1#; #^status:.*$#status:No carrier detect#' ${fb_send} fi ;; esac