#!/bin/sh #---------------------------------------------------------------------------- #/var/install/bin/eisfax-edit-send-test-fax # # Creation: 2005-09-08 hb # Last Update: $Id$ # # Copyright (c) 2005-@@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. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # include parameter . /var/lib/eisfax/eisfax.info # read configuration . /etc/config.d/eisfax # --------------------------------------------------------------------------- # use FritzBox # --------------------------------------------------------------------------- use_fritzbox() { echo ask_tmpfile=$(mktemp -t ask.XXXXXXXXXX) ${ASK} "Enter the Outgoing MSN" '' "0-999999999999999" "^$=Return" "0=Exit" >${ask_tmpfile} rc=${?} read outgoingmsn < ${ask_tmpfile} rm -f ${ask_tmpfile} if [ ${rc} = 255 ] then outgoingmsn=0 fi fb_type=${EISFAX_FRITZBOX_CONTR_TYPE} case ${fb_type} in ISDN) fb_msn="${outgoingmsn}" fb_contr="1" ;; 4|Analog) fb_msn="unknown" fb_contr="4" ;; VOIP) fb_msn="${outgoingmsn}" fb_contr="5" ;; *) fb_msn="${outgoingmsn}" fb_contr="${fb_type}" ;; esac case ${outgoingmsn} in '') exit 0 ;; 0) exit 127 ;; *) echo ${SEND_FRITZBOX} -send ${FAXFILE} ${fb_contr} ${fb_msn} ${faxnumber} echo anykey ;; esac } # --------------------------------------------------------------------------- # use ISDN # --------------------------------------------------------------------------- use_isdn() { echo ask_tmpfile=$(mktemp -t ask.XXXXXXXXXX) ${ASK} "Enter the Outgoing MSN" '' "0-999999999999999" "^$=Return" "0=Exit" >${ask_tmpfile} rc=${?} read outgoingmsn < ${ask_tmpfile} rm -f ${ask_tmpfile} if [ ${rc} = 255 ] then outgoingmsn=0 fi case ${outgoingmsn} in '') exit 0 ;; 0) exit 127 ;; *) echo ${SEND_ISDN} -f TIFF -L -v -c OutgoingMSN:${outgoingmsn} -d ${faxnumber} ${FAXFILE} echo anykey ;; esac } # --------------------------------------------------------------------------- # use ANALOG # --------------------------------------------------------------------------- use_analog() { modem_device='' send_modem='' # get ttyS? device if [ ${EISFAX_ANALOG_N} -gt 1 ] then echo mecho --info "Active modem device" echo idx=1 while [ "${idx}" -le "${EISFAX_ANALOG_N}" ] do eval active='${EISFAX_ANALOG_'${idx}'_ACTIVE}' if [ "${active}" = "yes" ] then eval device='${EISFAX_ANALOG_'${idx}'_DEVICE}' if [ -z "${modem_device}" ] then modem_device=$(echo "${device}") else modem_device=$(echo "${modem_device}"; echo "${device}") fi fi idx=$((${idx} + 1)) done # sort list modem_device=$(echo "${modem_device}" | sort) idx=1 # show list techo --begin '3 3r 1 32' echo "${modem_device}" | while read line do line="$(echo "${line}" | sed 's/^ *//')" techo --row "" "${idx}" "" "${line}" idx=$((${idx} + 1)) done techo --end echo ask_tmpfile=$(mktemp -t ask.XXXXXXXXXX) ${ASK} "Select" "" "1-S(echo "${modem_device}" | wc -l)" "^$=Return" "0=Exit" >${ask_tmpfile} rc=${?} read answer < ${ask_tmpfile} rm -f ${ask_tmpfile} if [ ${rc} = 255 ] then answer=0 fi case ${answer} in '') exit 0 ;; 0) exit 127 ;; *) # extract device from list action_line="$(echo "${modem_device}" | sed -n "${answer}p" | sed 's/^ *//')" send_modem="-h ${action_line}@localhost" ;; esac fi echo ${SEND_ANALOG} -n ${send_modem} -d ${faxnumber} ${FAXFILE} echo echo ${FAXSTAT_EXEC} -s | sed 's/HylaFAX/EisFAX/' echo echo anykey } # --------------------------------------------------------------------------- # show value # --------------------------------------------------------------------------- SHOW() { clrhome mecho --info "Send test fax" echo mecho --info "You can send a testfax throught" mecho --info "the fax number where ever you want" cat <${ask_tmpfile} rc=${?} read faxnumber < ${ask_tmpfile} rm -f ${ask_tmpfile} if [ ${rc} = 255 ] then faxnumber=0 fi case "${faxnumber}" in '') exit 0 ;; 0) exit 127 ;; *) send_value='' _level=0 # check what is use if [ "${EISFAX_ISDN_USE}" = "yes" ] then # ISDN = level 1 _level=$((${_level} + 1 )) fi if [ "${EISFAX_ANALOG_USE}" = "yes" ] then # Anlog = level 3 _level=$((${_level} + 3 )) fi if [ "${EISFAX_FRITZBOX_USE}" = "yes" ] then # FritzBox = level 5 _level=$((${_level} + 5 )) fi case ${_level} in 1) use_isdn ;; 3) use_analog ;; 4) # level 1 + 3 send_value="ISDN:isdn Analog:analog" ;; 5) use_fritzbox ;; 8) # level 3 + 5 send_value="FritzBox:fritzbox Analog:analog" ;; *) : ;; esac if [ -n "${send_value}" ] then echo mecho --info "Please select your test line." echo idx=1 techo --begin '3 3r 1 32' echo "${send_value}" | while read line do _OLD_IFS=${IFS} IFS=: set -- ${line} IFS=${_OLD_IFS} first="$(echo "${1}" | sed 's/^ *//')" techo --row "" "${idx}" "" "${first}" idx=$((${idx} + 1 )) done techo --end echo ask_tmpfile=$(mktemp -t ask.XXXXXXXXXX) ${ASK} "Select" "" "1-$(echo "${send_value}" | wc -l)" "^$=Return" "0=Exit" >${ask_tmpfile} rc=${?} read answer < ${ask_tmpfile} rm -f ${ask_tmpfile} if [ ${rc} = 255 ] then answer=0 fi case ${answer} in '') exit 0 ;; 0) exit 127 ;; *) # extract value action_line="$(echo "${send_value}" | sed -n "${answer}p" | sed 's/^ *//')" _OLD_IFS=${IFS} IFS=: # set action line set -- ${action_line} IFS=${_OLD_IFS} # $2 -> send_value use_${2} ;; esac fi ;; esac exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------