#! /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
# NOTE: Not just anybody can connect to your server; the list of allowed
# hostnames is a regexp. Check /usr/share/festival/festival.scm for more
# helpful comments; add your settings to /etc/festival.scm.
#

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:audio --background \
		--exec $DAEMON -- --server
    echo "done."
    ;;
  stop)
    echo -n "Stopping Festival server: "
    start-stop-daemon --stop --oknodo --exec $REALPROC
    echo "done."
    ;;
  restart|reload|force-reload)
    echo "Restarting Festival server: "
    start-stop-daemon --stop --oknodo --exec $REALPROC
    start-stop-daemon --start --chuid nobody:audio --background \
		--exec $DAEMON -- --server
    echo "done."
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
    exit 1
    ;;
esac

exit 0
