Extension:SphinxSearch/init.d

From mediawiki.org

Here is a chkconfig compatible script for FC users. It is a modification on a script by Vladimir Fedorkov. This script assumes you've put the pid file (config in sphinx.conf) in /var/run for selinux purposes. Speaking of selinux, you'll need to add port 3312 to the http port context.

#!/bin/bash
#
# Init file for searchd
#
# chkconfig: 2345 55 25
#
# description: searchd
#
# USE "chkconfig --add searchd" to configure Sphinx searchd service
#
# original script and all credit to Vladimir Fedorkov Mar 1, 2006, info@astellar.com
#
# modified by zerosys
#
# public domain

# Source function library.
. /etc/rc.d/init.d/functions

BASE_PATH=/path_to_sphinx
PID_FILE=/var/run/searchd.pid
CONFIG_FILE=$BASE_PATH/etc/sphinx.conf

EXEC_PATH=$BASE_PATH/bin
LOG_PATH=$BASE_PATH/var/log

RETVAL=0
prog="searchd"

do_start() {
        echo "Starting $prog"
        daemon $EXEC_PATH/$prog --config $CONFIG_FILE
        RETVAL=$?
        echo
        return $RETVAL
}

do_stop() {
        echo "Stopping $prog"
        if [ -e $PID_FILE ] ; then
                kill -15 `cat $PID_FILE`
                sleep 5
                if [ -e $PID_FILE ] ; then
                        kill -9 `cat $PID_FILE`
                fi
        fi
        RETVAL=$?
        echo
      return $RETVAL
}

case $* in

start)
        do_start
        ;;

stop)
        do_stop
        ;;

*)
        echo "usage: $0 {start|stop|}" >&2

        exit 1
        ;;
esac

exit $RETVAL