#!/bin/sh # # Setup cpufreq governor # # chkconfig: 2345 35 65 # description: this script can load cpufreq support for your CPU (not implemented) and \ # sets up the default cpufreq governor specified in /etc/sysconfig/cpufreq-primitive. \ # (It can be configured using alterator-.... -- not implemented.) \ # Enabling this script won't harm any other complex cpufreq-controlling daemons \ # started further (powersaved, cpufreqd, Gnome power management etc.), \ # they will override the default governor. # # Initial version: imz@altlinux.org 2008-03-28. WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions LOCKFILE=/var/lock/subsys/cpufreq-primitive CONFFILE=/etc/sysconfig/cpufreq-primitive setDefaultGovernor() { [[ -s "$CONFFILE" ]] || return 1 . "$CONFFILE" [[ "$DEFAULTGOVERNOR" ]] || return 1 action $"Setting default cpufreq governor: $DEFAULTGOVERNOR" \ cpufreq-set -g "$DEFAULTGOVERNOR" } ensureGovernors() { action $"Loading support for all cpufreq governors" \ modprobe --all cpufreq_{ondemand,conservative,powersave,userspace} } case "$1" in condrestart|condreload) # Nothing to do on condrestart because otherwise we could # damage a custom cpufreq-policy. : ;; start|restart|reload) # Ensure that all governors are loaded # (Gnome power manager doesn't want to load them itself and # doesn't do his complex policy if they are not loaded. # So we load them beforehand.) ensureGovernors # Read the config and set the values setDefaultGovernor && \ touch "$LOCKFILE" ;; stop|condstop) # Nothing to do when stopping (perhaps save the current governor?). rm -f "$LOCKFILE" ;; status) if [[ -f "$LOCKFILE" ]]; then stat --format=$"This service was last time (re-)started at %y." "$LOCKFILE" echo $"This doesn't mean there have not been perfomed any other (\"non primitive\") cpufreq policy changes since the given time." else echo $"This service hasn't been started since stopped last time." echo $"This does mean nothing at all (stopping the service doesn't affect the current cpufreq policy)." fi cpufreq-info exit 0 ;; *) msg_usage "${0##*/} {start|stop|restart|reload|status|condrestart|condreload|condstop}" exit 1 esac exit 0