#! /bin/sh # Init script for powernowd # ### BEGIN INIT INFO # Provides: powernowd # Required-Start: $syslog $local_fs $time # Required-Stop: $syslog $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start powernowd . ### END INIT INFO PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/sbin/powernowd NAME=powernowd DESC=powernowd OPTIONS="-q" test -x $DAEMON || exit 0 # modify the file /etc/default/powernowd if you want to add personal options [ -f /etc/default/$NAME ] && . /etc/default/$NAME # Get lsb functions . /lib/lsb/init-functions . /etc/default/rcS if [ "x$VERBOSE" = "xno" ]; then MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q" export MODPROBE_OPTIONS fi set -e load_modules() { modprobe cpufreq-userspace || return 1 #cpufreq is built in on powerpc; just return [ "`uname -m`" = "ppc" ] && return 0 #new style detection system if [ "$FREQDRIVER" ]; then modprobe "$FREQDRIVER" else . /usr/share/powernowd/cpufreq-detect.sh [ "$MODULE" ] && (modprobe "$MODULE" || modprobe "$MODULE_FALLBACK") fi if [ "`uname -m`" = "x86_64" ]; then modprobe powernow-k8 || true fi } check_kernel() { CPUFREQ=/sys/devices/system/cpu/cpu0/cpufreq if [ -f "$CPUFREQ/scaling_governor" ] && \ [ -f "$CPUFREQ/scaling_available_governors" ] && \ grep -q userspace "$CPUFREQ/scaling_available_governors" then return 0 else return 1 fi } start() { log_begin_msg "Starting $DESC... " load_modules if check_kernel then start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- $OPTIONS >/dev/null 2>&1 || { status=$? log_end_msg $status return $status } else log_action_cont_msg "CPU frequency scaling not supported" fi log_end_msg 0 return 0 } case "$1" in start) start ;; stop) log_begin_msg "Stopping $DESC: " start-stop-daemon --stop --quiet --oknodo --exec $DAEMON for x in /sys/devices/system/cpu/cpu[0-9]*/; do if [ -f $x"cpufreq/scaling_governor" ]; then echo -n performance > $x"cpufreq/scaling_governor"; fi done log_end_msg $? ;; restart|force-reload) $0 stop sleep 1 $0 start ;; *) N=/etc/init.d/$NAME log_success_msg "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0