#!/bin/bash

# Init file for sephiroth daemon
#
# chkconfig: 2345 95 20
# description: Sephiroth say2 server daemon
#
# processname: sephiroth
# config: /etc/sephirothrc
# pidfile: /var/run/sephiroth.pid

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

RETVAL=0

case "$1" in
  start)
	echo -n "Starting sephiroth: "
	if [ ! -f /var/run/sephiroth.pid ] ; then
	  case "`type -type success`" in
	    function)
	      /usr/local/bin/sephiroth && success "sephiroth startup" || failure "sephiroth startup"
	      RETVAL=$?
	    ;;
	    *)
              /usr/local/bin/sephiroth && echo -n "sephiroth "
	      RETVAL=$?
	    ;;
	  esac
	  [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sephiroth
	fi
	echo
	;;
  stop)
	echo -n "Shutting down sephiroth: "
	if [ -f /var/run/sephiroth.pid ] ; then
		killproc sephiroth
	fi
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sephiroth
	;;
  restart)
        $0 stop
        $0 start
	RETVAL=$?
        ;;
  status)
        status sephiroth
	RETVAL=$?
        ;;
  *)
	echo "Usage: sephiroth {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL
