3
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
5
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
6
# Further changes by Javier Fernandez-Sanguino <jfs@debian.org>
7
# Modified for sphinx by Radu Spineanu <radu@debian.org>
12
# Provides: sphinxsearch
13
# Required-Start: $local_fs $remote_fs $syslog $network $time
14
# Required-Stop: $local_fs $remote_fs $syslog $network
15
# Default-Start: 2 3 4 5
17
# Short-Description: Fast standalone full-text SQL search engine
21
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
22
DAEMON=/usr/bin/searchd
26
test -x $DAEMON || exit 0
28
LOGDIR=/var/log/sphinxsearch
29
PIDFILE=/var/run/sphinxsearch/searchd.pid
30
DODTIME=1 # Time to wait for the server to die, in seconds
31
# If this value is set too low you might not
32
# let some servers to die gracefully and
33
# 'restart' will not work
37
# Include sphinxsearch defaults if available
38
if [ -f /etc/default/sphinxsearch ] ; then
39
. /etc/default/sphinxsearch
42
if [ "$START" != "yes" ]; then
43
echo "To enable $NAME, edit /etc/default/sphinxsearch and set START=yes"
50
# Make sure the pidfile directory exists with correct permissions
51
piddir=`dirname "$PIDFILE"`
52
if [ ! -d "$piddir" ]; then
54
chown -R sphinxsearch "$piddir"
55
chgrp -R sphinxsearch "$piddir"
61
# Check if a given process pid's cmdline matches a given name
64
[ -z "$pid" ] && return 1
65
[ ! -d /proc/$pid ] && return 1
66
cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
67
# Is this the expected child?
68
[ "$cmd" != "$name" ] && return 1
74
# Check if the process is running looking at /proc
75
# (works for all users)
77
# No pidfile, probably no daemon present
78
[ ! -f "$PIDFILE" ] && return 1
79
# Obtain the pid and check it against the binary name
81
running_pid $pid $DAEMON || return 1
86
# Forcefully kill the process
87
[ ! -f "$PIDFILE" ] && return
91
[ -n "$DODTIME" ] && sleep "$DODTIME"s
94
[ -n "$DODTIME" ] && sleep "$DODTIME"s
96
echo "Cannot kill $NAME (pid=$pid)!"
105
# Check if we have the configuration file
106
if [ ! -f /etc/sphinxsearch/sphinx.conf ]; then
108
echo "Please create an /etc/sphinxsearch/sphinx.conf configuration file."
109
echo "A template is provided as /etc/sphinxsearch/sphinx.conf.sample."
113
start-stop-daemon --start --pidfile $PIDFILE --chuid sphinxsearch --exec ${DAEMON}
116
start-stop-daemon --stop --quiet --oknodo --user sphinxsearch --pidfile $PIDFILE \
122
echo -n "Starting $DESC: "
124
[ -n "$STARTDELAY" ] && sleep $STARTDELAY
133
echo -n "Stopping $DESC: "
138
echo -n "Forcefully stopping $DESC: "
146
restart|reload|force-reload)
147
echo -n "Restarting $DESC: "
149
[ -n "$DODTIME" ] && sleep $DODTIME
165
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
166
echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2