diff options
-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 |