File sphinx.init of Package sphinx
#!/bin/sh
#
# /etc/init.d/rcsphinx
#
### BEGIN INIT INFO
# Provides: sphinx
# Required-Start: boot.localnet mysql apache2
# Should-Start: $null
# Required-Stop: $null
# Should-Stop: $null
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Free open-source SQL full-text search engine
# Description: Sphinx is a full-text search engine, distributed under GPL version 2.
# Commercial licensing is also available upon request.
# Generally, it's a standalone search engine, meant to provide fast,
# size-efficient and relevant fulltext search functions to other
# applications. Sphinx was specially designed to integrate well with SQL
# databases and scripting languages. Currently built-in data source
# drivers support fetching data either via direct connection to MySQL,
# PostgreSQL, or from a pipe in a custom XML format.
#
# As for the name, Sphinx is an acronym which is officially decoded as
# SQL Phrase Index. Yes, I know about CMU's Sphinx project.
#
### END INIT INFO
# Check for binary
SPHINX_SEARCHD_BIN=/usr/bin/sphinx-searchd
test -x $SPHINX_SEARCHD_BIN || exit 5
# Parameters (startup)
SPHINX_SEARCHD_PARA="--config /etc/sphinx/sphinx.conf";
SPHINX_SEARCHD_PIDDIR="/var/run";
SPHINX_SEARCHD_PID=$SPHINX_SEARCHD_PIDDIR/searchd.pid;
# Source LSB init functions
# providing start_daemon, killproc, pidofproc,
# log_success_msg, log_failure_msg and log_warning_msg.
# This is currently not used by UnitedLinux based distributions and
# not needed for init scripts for UnitedLinux only. If it is used,
# the functions from rc.status should not be sourced or used.
#. /lib/lsb/init-functions
. /etc/rc.status
# Reset status of this service
rc_reset
case "$1" in
start)
if [ ! -d $SPHINX_SEARCHD_PIDDIR ]; then
mkdir -p $SPHINX_SEARCHD_PIDDIR;
fi
if [ -e $SPHINX_SEARCHD_PID ]; then
if checkproc $SPHINX_SEARCHD_BIN ; then
echo "Sphinx search daemon already started. Not starting."
exit 0;
else
echo "Removing stale PID file $SPHINX_SEARCHD_PID.";
rm -f $SPHINX_SEARCHD_PID;
fi
fi
echo -n "Starting Sphinx search daemon";
startproc -q -p $SPHINX_SEARCHD_PID $SPHINX_SEARCHD_BIN $SPHINX_SEARCHD_PARA
rc_status -v
;;
stop)
echo -n "Shutting down Sphinx daemon"
killproc -p $SPHINX_SEARCHD_PID -TERM $SPHINX_SEARCHD_BIN
rc_status
rm -f $SPHINX_SEARCHD_PID;
rc_status -v
;;
try-restart)
$0 status >/dev/null && $0 restart
rc_status
;;
restart)
$0 stop
$0 start
;;
force-reload)
echo -n "Reload service Sphinx daemon"
$0 stop && $0 start
rc_status
;;
reload)
rc_failed 3
rc_status -v
;;
status)
echo -n "Checking for service Sphinx daemon"
checkproc $SPHINX_SEARCHD_BIN
rc_status -v
;;
probe)
## Optional: Probe for the necessity of a reload, print out the
## argument to this init script which is required for a reload.
## Note: probe is not (yet) part of LSB (as of 1.2)
# test /etc/FOO/FOO.conf -nt /var/run/FOO.pid && echo reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
exit 1
;;
esac
rc_exit