#!/bin/sh #---------------------------------------------------------------------------- # /usr/bin/faxdel # # Creation: 2006-03-14 hb # Last Update: $Id$ # # Copyright (c) 2005-@@YEAR@@ Holger Bruenjes, holgerbruenjes(at)gemx(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 paramter . /var/lib/eisfax/eisfax.info # --------------------------------------------------------------------------- # show job # --------------------------------------------------------------------------- show_job() { clrhome mecho --info "EisFAX administration" echo mecho "Here you can remove an unsent fax job from the send queue." echo ${FAXSTAT_EXEC} -s | ${SED} 's/HylaFAX/EisFAX/' if ! $(${FAXSTAT_EXEC} -s | ${GREP} -q JID) then echo mecho "No active jobs found." fi echo mecho --info "JobID" echo _ask_file=$(${MKTEMP} -t ask.XXXXXXXXXX) ${ASK} "Select JobID" '' "0-999999999999" "^$=Return" "0=Exit" >${_ask_file} rc=${?} read jobid < ${_ask_file} ${RM} -f ${_ask_file} if [ ${rc} = 255 ] then exit 1 fi case ${jobid} in '') exit 0 ;; 0) exit 127 ;; *) ${FAXRM_EXEC} -a ${jobid} ;; esac show_job } # --------------------------------------------------------------------------- # fax to database # --------------------------------------------------------------------------- fax_to_database() { # change into HylaFAX spooldir cd ${HYLAFAX_DIR} if ${_recv:-false} then for _fax in ${recv_files} do _fax_rec="$(${CAT} tmp/${_fax})" ${RM} -f tmp/${_fax} _OLD_IFS=${IFS} IFS=':' set -- ${_fax_rec} IFS=${_OLD_IFS} bin/faxrcvd-local "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" "${7}" done fi if ${_send:-false} then for _fax in ${send_files} do _fax_send="$(${CAT} tmp/${_fax})" ${RM} -f tmp/${_fax} _OLD_IFS=${IFS} IFS='|' set -- ${_fax_send} IFS=${_OLD_IFS} bin/notify-local "${1}" "${2}" "${3}" "${4}" done fi # do exit if done, nothing more exit 0 } # --------------------------------------------------------------------------- # show menu # --------------------------------------------------------------------------- show_menu() { clrhome mecho --info "EisFAX administration" echo mecho "Please select the action." echo fax_tmp="${HYLAFAX_DIR}/tmp" recv_files="$(${LS} ${fax_tmp}/ 2>/dev/null | ${GREP} '^RECV')" send_files="$(${LS} ${fax_tmp}/ 2>/dev/null | ${GREP} '^SEND')" if [ -n "${recv_files}" ] then _recv=true _fax=true fi if [ -n "${send_files}" ] then _send=true _fax=true fi action_entry="Reenter fax file to database:fax_to_database Delete unsent fax job:show_job" if ${_fax:-false} then techo --begin '3 3r 2 32' techo --row "" --info No "" --info Action idx=1 echo "${action_entry}" | while read line do # set IFS to : without techo line _OLD_IFS=${IFS} IFS=':' set -- ${line} IFS=${_OLD_IFS} entry="$(echo "${1}" | ${SED} 's/^ *//')" techo --row "" "${idx}" "" "${entry}" idx=$((${idx} + 1)) done techo --end echo echo _ask_file=$(${MKTEMP} -t ask.XXXXXXXXXX) ${ASK} "Select" "" "1-$(echo "${action_entry}" | ${WC} -l)" "^$=Return" "0=Exit" >${_ask_file} rc=${?} read action_to_do < ${_ask_file} ${RM} -f ${_ask_file} if [ ${rc} = 255 ] then action_to_do=0 fi case ${action_to_do} in '') exit 0 ;; 0) exit 127 ;; *) _action="$(echo "${action_entry}" | ${AWK} -F: 'FNR == '${action_to_do}' { print $2 }')" ${_action} ;; esac else show_job fi } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- main() { show_menu exit 0 } # --------------------------------------------------------------------------- # call function main # --------------------------------------------------------------------------- main "${@}" # ---------------------------------------------------------------------------- # end # ----------------------------------------------------------------------------