cpupower.initd 807 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2013 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. CPUFREQ_SYSFS=/sys/devices/system/cpu/cpufreq
  5. change() {
  6. local c ret=0 opts="$1"
  7. if [ -n "$opts" ] ; then
  8. ebegin "Running cpupower -c all frequency-set ${opts}"
  9. cpupower -c all frequency-set ${opts} >/dev/null 2>&1
  10. : $(( ret += $? ))
  11. eend ${ret}
  12. if [ -d ${CPUFREQ_SYSFS} ] && [ -n "${SYSFS_EXTRA}" ] ; then
  13. c=1
  14. einfo "Setting extra options: ${SYSFS_EXTRA}"
  15. if cd ${CPUFREQ_SYSFS} ; then
  16. local o v
  17. for o in ${SYSFS_EXTRA} ; do
  18. v=${o#*=}
  19. o=${o%%=*}
  20. echo ${v} > ${o} || break
  21. done
  22. c=0
  23. fi
  24. eend ${c}
  25. : $(( ret += c ))
  26. fi
  27. fi
  28. return ${ret}
  29. }
  30. start() {
  31. change "${START_OPTS}"
  32. }
  33. stop() {
  34. change "${STOP_OPTS}"
  35. }