#!/bin/bash
#
# Init file for Gitorious Ultrasphinx daemon
#
# chkconfig: 2345 55 25
# description: Ultrasphinx server daemon
#
# processname: searchd
# pidfile: /var/www/gitorious/db/sphinx/log/searchd.pid
 
RETVAL=0
START_CMD="cd /var/www/gitorious/ && rake ultrasphinx:daemon:start RAILS_ENV=production"
STOP_CMD="cd /var/www/gitorious/ && rake ultrasphinx:daemon:stop RAILS_ENV=production"
RESTART_CMD="cd /var/www/gitorious/ && rake ultrasphinx:daemon:restart RAILS_ENV=production"
STATUS_CMD="cd /var/www/gitorious/ && rake ultrasphinx:daemon:status RAILS_ENV=production"
LOCK_FILE=/var/lock/git-ultrasphinx
PID_FILE=/var/www/gitorious/db/sphinx/log/searchd.pid
 
case "$1" in
  start)
    /bin/su - git -c "$START_CMD"
    ;;
  stop)
    /bin/su - git -c "$STOP_CMD"
    ;;
  status)
    /bin/su - git -c "$STATUS_CMD"
    ;;
        restart)
    /bin/su - git -c "$RESTART_CMD"
                ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    RETVAL=1
esac
exit $RETVAL