Skip to content

Instantly share code, notes, and snippets.

@devkral
Created January 7, 2012 19:18
Show Gist options
  • Save devkral/1575699 to your computer and use it in GitHub Desktop.
Save devkral/1575699 to your computer and use it in GitHub Desktop.
splitted init file
#!/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:
[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
#! /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