summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-04-22 16:02:38 +0000
committerColin Guthrie <colin@mageia.org>2012-04-22 16:02:38 +0000
commit2487c865234ee1629e149c60753cca65cb5949a2 (patch)
tree36917f7a53afa4ebed805409a120ed48eb86233b
parentf35d5421ed08ff576566aded33fcf3d3a5fd33e3 (diff)
downloadcpufreq-2487c865234ee1629e149c60753cca65cb5949a2.tar
cpufreq-2487c865234ee1629e149c60753cca65cb5949a2.tar.gz
cpufreq-2487c865234ee1629e149c60753cca65cb5949a2.tar.bz2
cpufreq-2487c865234ee1629e149c60753cca65cb5949a2.tar.xz
cpufreq-2487c865234ee1629e149c60753cca65cb5949a2.zip
Restore init script as mga2 supports both systemd and sysvinit.
-rw-r--r--cpufreq.init69
1 files changed, 69 insertions, 0 deletions
diff --git a/cpufreq.init b/cpufreq.init
new file mode 100644
index 0000000..e3a1a8f
--- /dev/null
+++ b/cpufreq.init
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+### BEGIN INIT INFO
+# Provides: cpufreq
+# Default-Start: 2 3 4 5
+# Short-Description: Set CPU frequency settings
+# Description: Set CPU frequency settings
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+start() {
+ gprintf "Setting CPU frequency settings: "
+ touch /var/lock/subsys/cpufreq
+ test -f /etc/sysconfig/cpufreq && . /etc/sysconfig/cpufreq
+ for cpu in /sys/devices/system/cpu/* ; do
+ [ "x$GOVERNOR" != "x" ] && [ -f $cpu/cpufreq/scaling_governor ] && echo $GOVERNOR > $cpu/cpufreq/scaling_governor
+ [ "x$MAX_FREQ" != "x" ] && [ -f $cpu/cpufreq/scaling_max_freq ] && echo $MAX_FREQ > $cpu/cpufreq/scaling_max_freq
+ [ "x$MIN_FREQ" != "x" ] && [ -f $cpu/cpufreq/scaling_min_freq ] && echo $MIN_FREQ > $cpu/cpufreq/scaling_min_freq
+ done
+ success
+ echo
+}
+
+real_stop() {
+ gprintf "Resetting CPU frequency settings: "
+ # make sure no governor module is in use first
+ # by switching to userspace governor (because it's built-in and won't modify frequency)
+ for cpu in /sys/devices/system/cpu/* ; do
+ [ -f $cpu/cpufreq/scaling_governor ] && echo userspace > $cpu/cpufreq/scaling_governor
+ done
+ rm -f /var/lock/subsys/cpufreq
+ success
+ echo
+}
+
+restart() {
+ real_stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ ;;
+ restart|reload)
+ restart
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/cpufreq ]; then
+ restart
+ fi
+ ;;
+ status)
+ [ -f /var/lock/subsys/cpufreq ]
+ RETVAL=$?
+ ;;
+ *)
+ gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" `basename $0`
+ RETVAL=1
+ ;;
+esac
+
+exit $RETVAL