#!/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/eisfax-server-log # # Creation: 2007-03-30 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 eisfax.info . /var/lib/eisfax/eisfax.info #exec 2> /tmp/eisfax-server-log-trace$$.log #set -x color='' frame='' if $(grep -qE "^MENU=['\"]/var/install/bin/show-menu['\"]" /etc/config.d/setup) then color='--nocolor' frame='--noframe' fi # set echo line, for allways equal echo_line=" ------------------------" # --------------------------------------------------------------------------- # select log # --------------------------------------------------------------------------- # check log files exists log_file=`ls /var/log/log.fax-* | sed 's#.*-##; s#\..*$##' | uniq` # added base file #log_file=`echo "${log_file}"; echo "eisfax"` # check for debug if `grep -q "^EISFAX_RESPOND_DEBUG='yes'" /etc/config.d/eisfax` then log_file=`echo "${log_file}"; echo "debug"` fi log_file=`echo "${log_file}" | sort` select_log () { clrhome echo mecho --info "Please select the log." echo techo --begin '3 3r 1 32' techo --row "" --info No "" --info Log-File mecho "${echo_line}" idx=1 echo "${log_file}" | while read log do techo --row "" "${idx}" "" "${log}" idx=`${EXPR_EXEC} ${idx} + 1` done mecho "${echo_line}" techo --end echo ${ASK} "Select" "" "1-`echo "${log_file}" | wc -l`" "^$=Return" "0=Exit" >/tmp/ask.$$ rc=${?} log_file_to_work=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ ${rc} = 255 ] then exit 127 fi case ${log_file_to_work} in '') exit 0 ;; 0) exit 127 ;; *) # extract log log_file_work="`echo "$log_file" | sed -n "${log_file_to_work}p" | sed 's/^ *//'`" case ${log_file_work} in eisfax) show_messages EisFAX: "select_log" ;; debug) show_debug_info ;; *) show_log_files ${log_file_work} ;; esac ;; esac } # --------------------------------------------------------------------------- # show log files # --------------------------------------------------------------------------- show_log_files () { clrhome log_files="${1}" get_log_files=`ls /var/log/log.fax-${log_files}* | sed 's#.*-##'` echo mecho --info "Please select the file." echo techo --begin '3 3r 1 32' techo --row "" --info No "" --info Log-File mecho "${echo_line}" idx=1 echo "${get_log_files}" | while read entry do techo --row "" "${idx}" "" "${entry}" idx=`${EXPR_EXEC} ${idx} + 1` done mecho "${echo_line}" techo --end # mecho ${ASK} "Select" "" "1-`echo "${get_log_files}" | wc -l`" "^$=Return" "0=Exit" >/tmp/ask.$$ rc=${?} read action_to_do < /tmp/ask.$$ rm -f /tmp/ask.$$ if [ ${rc} = 255 ] then exit 127 fi case ${action_to_do} in '') select_log ;; 0) exit 127 ;; *) # set working system log_file_work="`echo "$get_log_files" | sed -n "${action_to_do}p" | sed 's/^ *//'`" ${SHOW_DOC} $color $frame --follow --title ${log_files} \ /var/log/log.fax-${log_file_work} # case ${log_file_work} in # ${log_files}) # # show file entry # # ${SHOW_DOC} -t ${log_files} /var/log/log.fax-${log_file_work} # cat /var/log/log.fax-${log_file_work} | ${LESS} # # show_log_files ${log_files} # ;; # # *gz) # # extract file # gunzip -c /var/log/log.fax-${log_file_work} | ${LESS} #>/tmp/log-file$$ # # # show file entry # # ${SHOW_DOC} -t ${log_files} /tmp/log-file$$ # # # rm -f /tmp/log-file$$ show_log_files ${log_files} # ;; # esac ;; esac } # --------------------------------------------------------------------------- # show messages # --------------------------------------------------------------------------- show_messages () { log_files="${1}" return_des="${2}" # get EisFAX entry from messages file # grep "${log_files}" /var/log/messages | ${LESS} # >/tmp/log-file$$ grep "${log_files}" /var/log/messages >/tmp/log-file$$ if [ -s /tmp/log-file$$ ] then # show file entry ${SHOW_DOC} $color $frame --follow --title ${log_files} \ /tmp/log-file$$ fi rm -f /tmp/log-file$$ # return to function ${return_des} } # --------------------------------------------------------------------------- # debug infos # --------------------------------------------------------------------------- show_debug_info () { clrhome debug_log_file="fax-out printfax smb-spoolfile" echo mecho --info "Please select the debug file." echo techo --begin '3 3r 1 32' techo --row "" --info No "" --info Log-File mecho "${echo_line}" idx=1 echo "${debug_log_file}" | while read log do techo --row "" "${idx}" "" "${log}" idx=`${EXPR_EXEC} ${idx} + 1` done mecho "${echo_line}" techo --end echo ${ASK} "Select" "" "1-`echo "${debug_log_file}" | wc -l`" "^$=Return" "0=Exit" >/tmp/ask.$$ rc=${?} read debug_file_to_work < /tmp/ask.$$ rm -f /tmp/ask.$$ if [ ${rc} = 255 ] then exit 127 fi case ${debug_file_to_work} in '') select_log ;; 0) exit 127 ;; *) # set working system debug_file_work="`echo "$debug_log_file" | sed -n "${debug_file_to_work}p" | sed 's/^ *//'`" case ${debug_file_work} in printfax) show_messages ${debug_file_work} "show_debug_info" ;; fax-out) if [ -s /tmp/fax-debug.log ] then ${SHOW_DOC} $color $frame /tmp/fax-debug.log fi #cat /tmp/fax-debug.log | ${LESS} show_debug_info ;; smb-spoolfile) if [ -s /tmp/smb-spoolfile ] then ${SHOW_DOC} $color $frame /tmp/smb-spoolfile fi #cat /tmp/smb-spoolfile | ${LESS} show_debug_info ;; esac ;; esac } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- select_log echo ${ASK} "One more action?" "no" rc=${?} read a < /tmp/ask.$$ rm -f /tmp/ask.$$ if [ ${rc} = 255 ] then a=no fi if [ ${a} = no ] then exit 0 else select_log fi exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------