diff options
author | Kamil Rytarowski <kamil@mageia.org> | 2012-04-19 00:17:35 +0000 |
---|---|---|
committer | Kamil Rytarowski <kamil@mageia.org> | 2012-04-19 00:17:35 +0000 |
commit | ace003818893bd1ec750e1d7cacc2dccd6343ded (patch) | |
tree | 569d728fe60d325cd7874fcdb457039e521ea631 | |
parent | dae9046549885512b5dc412b9afb041cc4068ac6 (diff) | |
download | cpufreq-ace003818893bd1ec750e1d7cacc2dccd6343ded.tar cpufreq-ace003818893bd1ec750e1d7cacc2dccd6343ded.tar.gz cpufreq-ace003818893bd1ec750e1d7cacc2dccd6343ded.tar.bz2 cpufreq-ace003818893bd1ec750e1d7cacc2dccd6343ded.tar.xz cpufreq-ace003818893bd1ec750e1d7cacc2dccd6343ded.zip |
- adapt script for SystemD
-rw-r--r-- | cpufreq (renamed from cpufreq.init) | 38 | ||||
-rw-r--r-- | cpufreq.service | 13 |
2 files changed, 20 insertions, 31 deletions
@@ -1,19 +1,8 @@ #!/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 @@ -21,24 +10,19 @@ start() { [ "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: " +stop() { # 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 +reload() { + stop start } @@ -47,21 +31,13 @@ case "$1" in start ;; stop) + stop ;; - restart|reload) - restart - ;; - condrestart) - if [ -f /var/lock/subsys/cpufreq ]; then - restart - fi - ;; - status) - [ -f /var/lock/subsys/cpufreq ] - RETVAL=$? + reload) + reload ;; *) - gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" `basename $0` + echo "Usage: %s {start|stop|reload}" `basename $0` RETVAL=1 ;; esac diff --git a/cpufreq.service b/cpufreq.service new file mode 100644 index 0000000..92111c0 --- /dev/null +++ b/cpufreq.service @@ -0,0 +1,13 @@ +[Unit] +Description=A script for an init system to set CPU frequency settings + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/cpufreq start +ExecStop=/usr/bin/cpufreq stop +ExecReload=/usr/bin/cpufreq reload +StandardOutput=null + +[Install] +WantedBy=multi-user.target |