summaryrefslogtreecommitdiff
path: root/nonsystemd/cpupower-openrc/cpupower.initd
diff options
context:
space:
mode:
Diffstat (limited to 'nonsystemd/cpupower-openrc/cpupower.initd')
-rw-r--r--nonsystemd/cpupower-openrc/cpupower.initd41
1 files changed, 41 insertions, 0 deletions
diff --git a/nonsystemd/cpupower-openrc/cpupower.initd b/nonsystemd/cpupower-openrc/cpupower.initd
new file mode 100644
index 000000000..e65b599be
--- /dev/null
+++ b/nonsystemd/cpupower-openrc/cpupower.initd
@@ -0,0 +1,41 @@
+#!/usr/bin/openrc-run
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+CPUFREQ_SYSFS=/sys/devices/system/cpu/cpufreq
+
+change() {
+ local c ret=0 opts="$1"
+ if [ -n "$opts" ] ; then
+ ebegin "Running cpupower -c all frequency-set ${opts}"
+ cpupower -c all frequency-set ${opts} >/dev/null 2>&1
+ : $(( ret += $? ))
+ eend ${ret}
+
+ if [ -d ${CPUFREQ_SYSFS} ] && [ -n "${SYSFS_EXTRA}" ] ; then
+ c=1
+ einfo "Setting extra options: ${SYSFS_EXTRA}"
+ if cd ${CPUFREQ_SYSFS} ; then
+ local o v
+ for o in ${SYSFS_EXTRA} ; do
+ v=${o#*=}
+ o=${o%%=*}
+ echo ${v} > ${o} || break
+ done
+ c=0
+ fi
+ eend ${c}
+ : $(( ret += c ))
+ fi
+ fi
+
+ return ${ret}
+}
+
+start() {
+ change "${START_OPTS}"
+}
+
+stop() {
+ change "${STOP_OPTS}"
+}