#! /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 global PATH := '/sbin:/usr/sbin:/bin:/usr/bin' source /lib/init/vars.sh source /lib/lsb/init-functions global AVAILABLE := '"/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors'" matchstr $1 { start { start-stop-daemon --start --background --exec /etc/init.d/ondemand -- background } background { sleep 60 # probably enough time for desktop login test -f $AVAILABLE || exit 0 read governors < $AVAILABLE matchstr $governors { *interactive* { global GOVERNOR := '"interactive'" break } *ondemand* { global GOVERNOR := '"ondemand'" break } *powersave* { global GOVERNOR := '"powersave'" break } * { exit 0 } } for CPUFREQ in [/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor] { test -f $CPUFREQ || continue echo -n $GOVERNOR > $CPUFREQ } } restart|reload|force-reload { echo "Error: argument '$1' not supported" > !2 exit 3 } stop { } * { echo "Usage: $0 start|stop" > !2 exit 3 } }