#! /bin/sh ### BEGIN INIT INFO # Provides: ondemand # Required-Start: $remote_fs $all # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Set the CPU Frequency Scaling governor to "ondemand" ### END INIT INFO # Don't run if we're going to start an Android LXC container: test ! -f /etc/init/lxc-android-config.conf || exit 0 setglobal PATH = '/sbin:/usr/sbin:/bin:/usr/bin' source /lib/init/vars.sh source /lib/lsb/init-functions setglobal AVAILABLE = '"/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'" setglobal DOWN_FACTOR = '"/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor'" match $1 { with start start-stop-daemon --start --background --exec /etc/init.d/ondemand -- background with background sleep 60 # probably enough time for desktop login test -f $AVAILABLE || exit 0 read governors < $AVAILABLE match $governors { with *interactive* setglobal GOVERNOR = '"interactive'" break with *ondemand* setglobal GOVERNOR = '"ondemand'" match $[uname -m] { with ppc64* setglobal SAMPLING = '100' } break with *powersave* setglobal GOVERNOR = '"powersave'" break with * exit 0 } for CPUFREQ in [/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor] { test -f $CPUFREQ || continue echo -n $GOVERNOR > $CPUFREQ } if test -n $SAMPLING && test -f $DOWN_FACTOR { echo -n $SAMPLING > $DOWN_FACTOR } with restart|reload|force-reload echo "Error: argument '$1' not supported" > !2 exit 3 with stop with * echo "Usage: $0 start|stop" > !2 exit 3 }