#!/bin/bash
#
# sophie    This shell script takes care of starting and stopping sophie
#
# chkconfig: 2345 80 30
# description: Sophie is a daemon for SAVI
# processname: sophie
# pidfile: /var/run/sophie.pid

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

[ -f /usr/bin/sophie ] || exit 0

start() {
        # Start daemons.
        echo -n $"Starting Sophie SAVI daemon: "
        daemon /usr/bin/sophie -D
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/sophie
}

stop() {
        # Stop daemons.
        echo -n $"Shutting down Sophie SAVI daemon: "
        killproc sophie
	RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/sophie
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  reload)
	restart
	;;
  status)
	status sophie
	;;
  *)
	echo $"Usage: sophie {start|stop|restart|reload|status|condrestart}"
	exit 1
esac

exit $RETVAL
