From d01c0872040feee7216269836377ed0a8aff43e3 Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 24 Oct 2006 13:22:54 +0000 Subject: [PATCH] *** empty log message *** --- src/index/rclmon.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 src/index/rclmon.sh diff --git a/src/index/rclmon.sh b/src/index/rclmon.sh new file mode 100755 index 00000000..d8a129bb --- /dev/null +++ b/src/index/rclmon.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# @(#$Id: rclmon.sh,v 1.1 2006-10-24 13:22:54 dockes Exp $ (C) 2006 J.F.Dockes +####################################################### +# 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 program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +###################################################### + +################### +# Start/stop a recollindex program running as permanent real time indexer. +# The running program writes its pid in $RECOLL_CONFDIR/rclmonpid +# The portability of this script has not been fully tested. +# + +fatal() +{ + echo $* + exit 1 +} +usage() +{ + fatal "Usage: rclmon.sh " +} + +test $# -eq 1 || usage + +export LANG=C + +RECOLL_CONFDIR=${RECOLL_CONFDIR:-$HOME/.recoll} +#echo RECOLL_CONFDIR = ${RECOLL_CONFDIR} + +pidfile="${RECOLL_CONFDIR}/rclmonpid" +opid=0 + + +if test -f $pidfile ; then + read opid junk < $pidfile +fi + +if test $opid -gt 0; then + out=`kill -0 ${opid} 2>&1` + if test $? -ne 0 ; then + if test `expr "$out" : '.*such *process.*'` -ne 0 ; then + opid=0 + else + fatal cant test existence of running process + fi + fi +fi + +#echo "Existing pid $opid" + +case $1 in + start) + if test "$opid" -ne 0 ; then + fatal "Already running process: $opid" + fi + recollindex -m + ;; + stop) + if test "$opid" -eq 0 ; then + fatal "No process running" + fi + kill $opid + ;; + *) + usage +esac +