CPU frequency fixer for GNU/Linux
[shellsnippets/shellsnippets.git] / mksh / sysadmin / schnell
1 #!/bin/mksh
2
3 # run as root
4 (( USER_ID )) && exec sudo "$0" "$@"
5
6 # run verbosely
7 set -x
8
9 # decide what to do
10 case x$1 {
11 (x|xauto)
12         for a in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo ondemand >$a; done
13         ;;
14 (x1|xon)
15         for a in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo performance >$a; done
16         ;;
17 (x0|xoff)
18         for a in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo powersave >$a; done
19         ;;
20 (*)
21         echo call with on/off/auto
22         exit 1
23         ;;
24 }
25 exit 0