|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /etc/rc.d/rc3.d/ |
Upload File : |
#!/bin/sh
# Startup script for cpuspeed
#
# chkconfig: 12345 06 99
# description: Run dynamic CPU speed daemon
# Source function library.
. /etc/rc.d/init.d/functions
[ -f /usr/sbin/cpuspeed ] || exit 0
prog="cpuspeed"
# Get config.
if [ -f /etc/cpuspeed.conf ]; then
. /etc/cpuspeed.conf
fi
cpu0freqd=/sys/devices/system/cpu/cpu0/cpufreq
testpat='/sys/devices/system/cpu/cpu*/cpufreq/scaling_driver'
some_file_exist() {
while [ "$1" ] ; do
[ -f "$1" ] && return 0
shift
done
return 1
}
start() {
if [ ! -f /var/lock/subsys/cpuspeed ] ; then
if ! some_file_exist $testpat ; then
# Attempt to load scaling_driver if not loaded
# but it is configured
if [ -n "$DRIVER" ]; then
/sbin/modprobe "$DRIVER"
else
if [ -d /proc/acpi ] &&
grep flags /proc/cpuinfo | \
grep -q est ; then
# use ACPI as a fallback
/sbin/modprobe acpi-cpufreq
# if even ACPI didn't work, remove it
# and then next test will bail out.
[ -d ${cpu0freqd} ] || \
/sbin/modprobe -r acpi-cpufreq
else
# No scaling. Just exit.
return 0
fi
fi
fi
# If we get this far with no driver, we must have no scaling.
# We're doomed.
[ ! -f ${cpu0freqd}/scaling_driver ] && return 0
drv=`cat ${cpu0freqd}/scaling_driver`
case "$drv" in
centrino|powernow-k8)
/sbin/modprobe cpufreq-ondemand
for i in /sys/devices/system/cpu/cpu*
do
echo ondemand > $i/cpufreq/scaling_governor
done
RETVAL=0
;;
*)
echo -n $"Starting $prog: "
daemon cpuspeed -d $OPTS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/cpuspeed
esac
else
return 0
fi
return $RETVAL
}
stop() {
[ ! -f ${cpu0freqd}/scaling_driver ] && return 0
drv=`cat ${cpu0freqd}/scaling_driver`
case "$drv" in
centrino|powernow-k8)
/sbin/modprobe -r cpufreq-ondemand
RETVAL=0
;;
*)
if test "x`pidof cpuspeed`" != x; then
echo -n $"Stopping $prog: "
killproc cpuspeed -USR1
killproc cpuspeed -INT
echo
fi
if test "x`pidof cpuspeed`" != x; then
killproc cpuspeed
fi
RETVAL=$?
esac
[ -n "$DRIVER" ] && /sbin/modprobe -r $DRIVER
[ $RETVAL = 0 ] && RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/cpuspeed
return $RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status cpuspeed
;;
restart)
stop
start
;;
condrestart)
if test "x`pidof cpuspeed`" != x; then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL