1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/bin/sh
### BEGIN INIT INFO
# Required-Start: $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: set CPUFreq kernel parameters
# Description: utilities to deal with CPUFreq Linux
# kernel support
### END INIT INFO
#
DESC="CPUFreq Utilities"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
CPUFREQ_SET=/usr/bin/cpufreq-set
CPUFREQ_INFO=/usr/bin/cpufreq-info
CPUFREQ_OPTIONS=""
# use lsb-base
. /lib/lsb/init-functions
[ -x $CPUFREQ_SET ] || exit 0
if [ -f /etc/default/cpufrequtils ] ; then
. /etc/default/cpufrequtils
else
ENABLE="false"
fi
# if not enabled then exit gracefully
[ "$ENABLE" = "true" ] || exit 0
if [ $MAX_SPEED -gt 0 ] ; then
CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --max $MAX_SPEED"
fi
if [ $MIN_SPEED -gt 0 ] ; then
CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --min $MIN_SPEED"
fi
#FAIL_MESG=""
if [ -n "$GOVERNOR" ] ; then
#GOVERNOR=$($CPUFREQ_INFO -g | sed -ne "s/.*\($GOVERNOR\).*/\1/p")
#if [ -n "$GOVERNOR" ] ; then
CPUFREQ_OPTIONS="$CPUFREQ_OPTIONS --governor $GOVERNOR"
#else
# FAIL_MESG="governor not available"
#fi
fi
CPUS=$(sed -ne 's/^processor[[:space:]]*: \([0-9]\+\)$/\1/p' /proc/cpuinfo)
RETVAL=0
case "$1" in
start|force-reload|restart|reload)
log_action_begin_msg "$DESC: Setting $GOVERNOR CPUFreq governor"
for cpu in $CPUS ; do
# if [ $(CPUFREQ_INFO -a --cpu $cpu) -eq $cpu ] ; then
log_progress_msg "CPU${cpu} "
$CPUFREQ_SET --cpu $cpu $CPUFREQ_OPTIONS 2>&1 > /dev/null || RETVAL=$?
# fi
done
log_action_end_msg $RETVAL "$FAIL_MESG"
;;
stop)
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac
exit 0
|