#! /bin/sh
#
# vdr start-stop script
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=vdr
DESC="vdr - Linux Video Disk Recorder"


# Defaults - don't touch, edit /etc/default/vdr

ENABLED=0

test -f /etc/default/vdr && . /etc/default/vdr

test "$ENABLED" != "0" || exit 0

test -x /usr/sbin/runvdr || exit 0

case "$1" in
  start)
	 echo -n "Starting $DESC: $NAME"
	 start-stop-daemon --start --quiet \
        	--exec /usr/sbin/runvdr -- $DAEMON \
		-v $VIDEO_DIR -c $CFG_DIR $OPTIONS \
		$PLUGINS &
	 echo "."
	 ;;
  stop)
	 echo -n "Stopping $DESC: $NAME  "
	  killall -q -TERM runvdr
	  killall -q -TERM $DAEMON
	 echo "."
	 ;;
  restart|force-reload)
	 echo -n "Restarting $DESC: $NAME  "
	 killall -q -TERM runvdr
	 killall -q -TERM $DAEMON
	 sleep 4
	 start-stop-daemon --start --quiet \
	  	--exec /usr/sbin/runvdr -- $DAEMON \
		-v $VIDEO_DIR -c $CFG_DIR $OPTIONS \
		$PLUGINS & 
	 echo "."
	 ;;
  *)
	 N=/etc/init.d/$NAME
	 echo "Use: $N {start|stop|restart|force-reload}" >&2
	 exit 1
	;;
esac

exit 0

