#!/usr/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/sn-search - search for groups in grouplist # # Creation : 2001 chriswue # Last update: $Id$ # # Copyright (c) 2001-2003 by Christian Wuerdig eisfair(at)chriswue(dot)de # Copyright (c) 2010-@@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. #---------------------------------------------------------------------------- . /var/install/include/eislib . /var/lib/sn/sn.info tmpserv="/tmp/.snserv" tmpgl="/tmp/.sngl" # --------------------------------------------------------------------------- # check if console minium 80x24 # --------------------------------------------------------------------------- check_screensize case ${?} in 0) : ;; *) exit 1 ;; esac # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- if [ ! -d ${OUTGOING} ] then echo mecho --warn "No external newsserver found." echo anykey exit 0 fi SN_TITLE="Searching for newsgroups in grouplist of external newsserver" export SN_TITLE /var/install/bin/sn-getserver ret="${?}" ns='' if [ -f ${tmpserv} ] then read ns < ${tmpserv} rm -f ${tmpserv} else exit ${ret} fi echo serverdir="${OUTGOING}/$ns:119" if [ -f $serverdir/grouplist ] then clrhome mecho -n --info "Enter your search string for server" mecho " '${ns}'" echo ask_tmpfile=$(${MKTEMP} -t XXXXXXXXXXXXX) ${ASK} "Expression to search for:" "" "*" > ${ask_tmpfile} rc=${?} read regexp < ${ask_tmpfile} rm -f ${ask_tmpfile} # if ask break, ask returned 255 if [ ${rc} = 255 ] then exit 0 fi if [ -z "${regexp}" ] then exit 0 fi echo echo "Scanning List" grep "$regexp" $serverdir/grouplist >${tmpgl} anz=$(grep -c "$regexp" $serverdir/grouplist) else mecho -n --warn "No grouplist found for" mecho " '${ns}'" echo anykey exit fi if [ "${anz:-0}" -eq 0 ] then echo mecho -n --warn "No newsgroups found matching" mecho " '$regexp'" anykey else SN_TITLE="${anz} newsgroups found matching" SN_SUBTITLE="\n [ ${regexp} ]" SN_FLAGS='--indent 12 --spread --list' SN_COLS='60*' SN_ROWS=0 export SN_TITLE export SN_SUBTITLE export SN_FLAGS export SN_COLS while read line do SN_ROWS=$((${SN_ROWS} + 1)) eval SN_${SN_ROWS}_1=\"${line}\" export SN_${SN_ROWS}_1 export SN_ROWS done < ${tmpgl} rm -f ${tmpgl} SN_QUESTION='View' export SN_QUESTION ask_tmpfile=$(${MKTEMP} -t XXXXXXXXXXXXX) ${CHOOSE} SN 1 > ${ask_tmpfile} rc=${?} read answer < ${ask_tmpfile} rm -f ${ask_tmpfile} # if ask break, ask returned 255 if [ ${rc} = 255 ] then answer=0 fi unset SN_FLAGS unset SN_SUBTITLE case ${answer} in '') : ;; 0) exit 127 ;; esac fi exit 0 # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------