#! /bin/sh
# /etc/init.d/festival
#
# Init script for starting Festival as a system-wide server process.
#
# Written by David Huggins-Daines <dhd@cepstral.com>

# Comment out the next line to start a Festival server at boot time.
exit 0

set -e

DAEMON=/usr/bin/festival
REALPROC=/usr/bin/festival
NAME=festival

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting Festival server: "
    start-stop-daemon --start --chuid nobody --background \
		--exec $DAEMON -- --server
    echo "done."
    ;;
  stop)
    echo -n "Stopping Festival server: "
    start-stop-daemon --stop --oknodo --exec $REALPROC
    echo "done."
    ;;
  restart)
    echo "Restarting Festival server: "
    start-stop-daemon --stop --oknodo --exec $REALPROC
    start-stop-daemon --start --chuid nobody --background \
		--exec $DAEMON -- --server
    echo "done."
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
