#!/bin/bash
#
# Init file for cpufreqd
#
# chkconfig: 2345 65 35
# description: cpufreqd - CPU frequency scaling daemon \
# cpufreqd is meant to be a replacement of the speedstep applet you \
# can find on some other OS, it monitors battery level, AC state and \
# running programs and adjusts the frequency of the processor according to \
# a set of rules specified in the config file (see cpufreqd.conf (5)). \
# processname: cpufreqd
# pidfile: /var/run/arpd.pid



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

RETVAL=0



start() {
	gprintf "Starting cpufreqd : "
	daemon cpufreqd

	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/cpufreqd
	echo
	return $RETVAL
}
	
stop() {
	gprintf "Stopping cpufreqd : "
	killproc cpufreqd
	RETVAL=$?
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/cpufreqd
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

	
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	condrestart)
		if [ -f /var/log/subsys/cpufreqd ]; then
			restart
		fi
		;;	
	status)
		status cpufreqd
		;;
	*)
		gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" `basename $0`
		RETVAL=1
		;;

esac

exit $RETVAL
