Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 0f697c318905af8acf8897cca79ce727 > files > 3

cpufreqd-2.4.2-4.mga1.i586.rpm

#!/bin/bash
#
# Init file for cpufreqd
#
# chkconfig: 2345 66 34
# 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

### BEGIN INIT INFO
# Provides: cpufreqd
# Should-Start: acpi cpufreq
# Should-Stop: acpi cpufreq
# Default-Start: 2 3 4 5
# Short-Description: CPU frequency scaling daemon
# Description: CPU frequency scaling daemon
### END INIT INFO

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

RETVAL=0

[ -d /sys/devices/system/cpu/cpu0/cpufreq ] || [ -f /proc/cpufreq ] || exit 0


start() {
	gprintf "Starting cpufreqd : "
	# tweak settings (select powermanagement, make sure no % are used on 2.6):
	gprintf "### This file is generated, please edit /etc/cpufreqd.conf instead.\n" \
	> /etc/cpufreqd/cpufreqd.conf.tmp
	cat /etc/cpufreqd.conf | perl -pi /usr/share/cpufreqd/cpufreq_defaults \
	>> /etc/cpufreqd/cpufreqd.conf.tmp
	daemon cpufreqd -f /etc/cpufreqd/cpufreqd.conf.tmp

	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
		RETVAL=$?
		;;
	*)
		gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" `basename $0`
		RETVAL=1
		;;

esac

exit $RETVAL