#!/bin/sh
#
# Start or stop the cpudyn.
#
# Written by Ricardo Galli <gallir@uib.es>

OPTS="-d -i 1 -p 0.5 0.90"
#OPTS="-d -i 1 -p 0.5 0.90 -t 120 -h /dev/hda"
PATH=/bin:/usr/bin:/sbin:/usr/sbin

test -s /usr/sbin/cpudynd || exit 0

[ -f /etc/default/rcS ] && . /etc/default/rcS

case "$1" in
    start)
	echo -n "Starting cpudynd: "
	start-stop-daemon --start --quiet --exec /usr/sbin/cpudynd -- $OPTS
	if [ $? = 0 ]; then
	    echo "cpudynd."
	else
	    echo "(failed.)"
	fi
	;;
    stop)
	echo -n "Stopping cpudynd: "
	start-stop-daemon --stop --retry=1 --quiet --oknodo --exec /usr/sbin/cpudynd
	echo "cpudynd."
	;;
    restart) 
	$0 stop
	$0 start
	exit
	;;
    *)
	echo "Usage: /etc/init.d/cpudynd {start|stop|restart}"
	exit 1
	;;
esac

exit 0
