Guest

riaan

By: a guest on Aug 2nd, 2009  |  syntax: Bash  |  size: 1.06 KB  |  hits: 188  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          ondemand
  4. # Required-Start:    $remote_fs $all
  5. # Required-Stop:
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:
  8. # Short-Description: Set the CPU Frequency Scaling governor to "ondemand"
  9. ### END INIT INFO
  10.  
  11.  
  12. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  13.  
  14. . /lib/init/vars.sh
  15. . /lib/lsb/init-functions
  16.  
  17. case "$1" in
  18.     start)
  19.         start-stop-daemon --start --background --exec /etc/init.d/ondemand -- background
  20.         ;;
  21.     background)
  22.         sleep 60 # probably enough time for desktop login
  23.  
  24.         for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  25.         do
  26.                 [ -f $CPUFREQ ] || continue
  27.                 echo -n ondemand > $CPUFREQ
  28.         done
  29.         for CPU_THRESHOLD in /sys/devices/system/cpu/cpu*/cpufreq/ondemand/up_threshold
  30.         do
  31.                 [ -f $CPU_THRESHOLD ] || continue
  32.                 echo -n 40 > $CPU_THRESHOLD
  33.         done
  34.         ;;
  35.     restart|reload|force-reload)
  36.         echo "Error: argument '$1' not supported" >&2
  37.         exit 3
  38.         ;;
  39.     stop)
  40.         ;;
  41.     *)
  42.         echo "Usage: $0 start|stop" >&2
  43.         exit 3
  44.         ;;
  45. esac