Created
January 7, 2012 19:18
-
-
Save devkral/1575699 to your computer and use it in GitHub Desktop.
splitted init file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. /etc/rc.conf | |
. /etc/rc.d/functions | |
case "$1" in | |
start|restart) | |
stat_busy "Setting cpupower rules" | |
if /usr/bin/cpupower_init.sh; then | |
stat_done | |
else | |
stat_append ': Invalid configuration' | |
stat_fail | |
fi | |
;; | |
*) | |
echo "usage: $0 {start|restart}" | |
esac | |
exit 0 | |
# vim:set ts=2 sw=2 ft=sh et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=This service adjust the cpu policies via cpupower. It uses the /etc/conf.d/cpupower file. | |
After=syslog.target | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/cpupower_init.sh | |
RemainAfterExit=false | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
[[ -f /etc/conf.d/cpupower ]] && . /etc/conf.d/cpupower | |
params='' | |
if [[ "$governor" ]]; then | |
grep -qw "$governor" /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors || modprobe -q cpufreq_${governor} | |
params="-g $governor " | |
params+="${min_freq:+-d $min_freq} " | |
params+="${max_freq:+-u $max_freq} " | |
params+="${freq:+-f $freq} " | |
cpupower -c all frequency-set $params >/dev/null | |
exit 0 | |
else | |
echo ': Invalid configuration; You have to choose a governor' | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment