File couchdb-lucene.init of Package couchdb-lucene

#! /bin/sh
### BEGIN INIT INFO
# Provides:          couchdb-lucene
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Should-Start:      $remote_fs
# Should-Stop:       $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Initscript for CouchDB-Lucene
# Description:       Initscript for CouchDB-Lucene on SuSE systems
### END INIT INFO

# Author: Marcello Barnaba <vjt@openssl.it>

. /etc/rc.status
rc_reset

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="CouchDB-Lucene Full Text Indexer Service"
NAME="couchdb-lucene"
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
COUCHDB_LUCENE_USER=couchdb-lucene

config="/etc/sysconfig/$NAME"
[ -e $config ] && . $config

# Exit if there is no daemon executable
[ -x "$DAEMON" ] || exit 0

case "$1" in
  start)
        echo -n "Starting $DESC"
        if ! checkproc -p $PIDFILE `which java`; then
          touch $PIDFILE
          chown $COUCHDB_LUCENE_USER: $PIDFILE
          export PIDFILE
          start_daemon -l /dev/null -u $COUCHDB_LUCENE_USER -p $PIDFILE -f $DAEMON $COUCHDB_LUCENE_OPTIONS
        fi
        rc_status -v
        ;;

  stop)
        echo -n "Stopping $DESC"
        killproc -p $PIDFILE -TERM -t 10 `which java`
        rc_status -v
        ;;

  status)
        echo -n "Checking for $DESC"
        checkproc -p $PIDFILE `which java`
        rc_status -v
        ;;

  restart|force-reload|try-restart)
        $0 stop
        sleep 1
        $0 start

        rc_status -v
        ;;

  *)
        echo "Usage: $0 {start|stop|status|restart}" >&2
        exit 1
        ;;
esac
rc_exit
openSUSE Build Service is sponsored by