#!/bin/sh
#
# Start or stop the cpudyn.
#
# Written by Ricardo Galli <gallir@uib.es>
#
# Adapted for Mandriva by Olivier Thauvin <thauvin@aerov.jussieu.fr>
#
# chkconfig: 345 66 34
# description: Cpudyn control the speed of CPU \
#              like Pentium III/IV or PowerPC
#
# processname: cpudynd 
### BEGIN INIT INFO
# Provides: cpudynd
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Short-Description: cpudynd
# Description: Cpudyn control the speed of CPU
#              like Pentium III/IV or PowerPC
### END INIT INFO


OPTS="-i 1 -p 0.5 0.90"
PATH=/bin:/usr/bin:/sbin:/usr/sbin

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

. /etc/rc.d/init.d/functions

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

case "$1" in
    start)
	gprintf "Starting cpudynd: "
	daemon cpudynd -d $OPTS
	RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cpudyn
    ;;
    stop)
	gprintf "Stopping cpudynd: "
	killproc cpudynd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cpudyn
	;;
    status)
        status cpudynd
        RETVAL=$?
    ;;
    restart|reload) 
	$0 stop
	$0 start
        RETVAL=$?
	;;
    *)
	gprintf "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac

exit $RETVAL
