#!/bin/sh
#
# nvtvd		NVidia TV-out daemon
#
# chkconfig:	345 90 10
#
# description:	NVidia TV-out daemon allows user to control TV-out


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

[ -f /etc/sysconfig/nvtv ] && . /etc/sysconfig/nvtv

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/nvtv ]; then
		msg_starting NvTV
		busy
		setsid nvtvd ${OPTIONS} </dev/null 2>/dev/null >/dev/null &
		RETVAL=$?
		if [ $RETVAL -eq 0 ]; then
			ok
			touch /var/lock/subsys/nvtv
		else
			fail
			RETVAL=1
		fi
	else
		msg_already_running NvTV
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/nvtv ]; then
		# Stop daemons.
		msg_stopping NvTV
		killproc nvtvd
		rm -f /var/lock/subsys/nvtv
	else
		msg_not_running NvTV
	fi
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  status)
	status nvtvd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
