#!/bin/sh
#
# Starts (and stops) the YIFF Sound System.
#
# This is *not* a Redhat restart script, however with slight modifications
# it can be.
#
# Edit paths as needed, espessially if you have customized the installation
# locations.
#

# Change the address or port number as needed (note that this
# default value is considered standard):
#
YIFFADDR=127.0.0.1:9433

# Paths (modify as needed):
#
PROGLOCK=/var/lock/subsys/yiff
PROGCFG=/usr/etc/yiffrc
YIFFSHUTDOWN=/usr/bin/yiffshutdown


case "$1" in
	start)
		# abort if already started
		[ -f $PROGLOCK ] && exit 0

		# This works only correctly if the user `nobody' is allowed
		# to be in the directory where this file is called
		# (for example: /root is NOT ok)

		echo -n "Starting yiff: "
                su nobody -c "/usr/sbin/yiff $PROGCFG &"
                touch $PROGLOCK

                echo "yiff"
                ;;

	stop)
		# Stop yiff.
		echo -n "Shutting down yiff: "
		su nobody -c "$YIFFSHUTDOWN --recorder $YIFFADDR"
		rm -f $PROGLOCK

		echo "yiff"
		;;

	restart)
		$0 stop   
		$0 start
		;;

	*)
		echo "Usage: starty {start|stop|restart}"
                exit 1
esac

exit 0
