piler/init.d/rc.searchd.in
Janos SUTO c0859cdd65 Added support for manticore
Signed-off-by: Janos SUTO <sj@acts.hu>
2022-08-27 11:03:29 +02:00

81 lines
1.4 KiB
Bash

#!/bin/sh
##
##
### BEGIN INIT INFO
# Provides: pilersearch
# Required-Start: $remote_fs $syslog $named $network $time
# Required-Stop: $remote_fs $syslog $named $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sphinxsearch
# Description: sphinxsearch
### END INIT INFO
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
NAME=searchd
PID_FILE=/var/run/piler/searchd.pid
PID_NUMBER=$(test -f ${PID_FILE} && cat ${PID_FILE})
CONFIG_FILE=sphinx.conf
if [ -f SYSCONFDIR/piler/MANTICORE ]; then
CONFIG_FILE=manticore.conf
fi
start() {
echo "starting searchd . . ."
if [ ! -d /var/run/piler ]; then
mkdir -p /var/run/piler
chown piler:piler /var/run/piler
fi
if [ $(id -u) -eq 0 ]; then
su piler -c "searchd --config SYSCONFDIR/piler/${CONFIG_FILE}"
else
searchd
fi
}
stop() {
echo "stopping searchd"
kill "$PID_NUMBER"
}
check_status(){
test -f /proc/${PID_NUMBER}/status
}
case "$1" in
start)
start;
;;
stop)
stop;
;;
status)
if check_status;
then
echo "${NAME} is running."
exit 0
else
echo "${NAME} is not running."
exit 1
fi
;;
restart)
stop;
sleep 1;
start;
;;
*)
echo "Usage: $0 start|stop|restart|status"
esac