Child: [5fb98c] (diff)

Download this file

rclmon.sh    81 lines (68 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/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 <start|stop>"
}
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