Sophie

Sophie

distrib > Mageia > 3 > i586 > media > core-release-src > by-pkgid > 43759b634b23e1640609ba80ce20ad5a > files > 3

powernowd-1.00-7.mga3.src.rpm

#!/bin/sh
# 
# Starts the powernowd daemon
#
# chkconfig: 345 66 34
# description: Controls the cpu frequency with powernowd
# processname: powernowd
#
### BEGIN INIT INFO
# Provides: powernowd
# Should-Start: harddrake cpufreq
# Default-Start: 3 4 5
# Short-Description: Starts the powernowd daemon
# Description: Controls the cpu frequency with powernowd
### END INIT INFO
#
# It unserstands "stop", "start", "restart", and these other commands:
# 	"dyn"   turn on dynamic control (alias to start, aka, run the daemon)
#	"high"	kill daemon, set cpu to high speed.
#	"low" 	kill daemon, set cpu to low speed.
#

# Source function library.
. /etc/rc.d/init.d/functions

OPTIONS=""
DAEMON=powernowd
PROGNAME=${DAEMON}

. /etc/sysconfig/powernowd

test -x /usr/sbin/$DAEMON || exit 0
RETVAL=0

start() {
	gprintf "Starting %s daemon: " "$DAEMON"
	daemon /usr/sbin/$PROGNAME $OPTIONS
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
	echo
    return $RETVAL
}

stop() {
	gprintf "Stopping %s daemon: " "$DAEMON"
	killproc $PROGNAME
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
	echo
    return $RETVAL
}

low() {
	stop
	for i in `/bin/ls /sys/devices/system/cpu/`; do 
	    pushd . >& /dev/null
	    cd /sys/devices/system/cpu/$i/cpufreq
	    cat scaling_min_freq > scaling_setspeed
	    popd >& /dev/null
	done
	start
}	

high() {
	stop
	for i in `/bin/ls /sys/devices/system/cpu/`; do 
	    pushd . >& /dev/null
	    cd /sys/devices/system/cpu/$i/cpufreq
	    cat scaling_max_freq > scaling_setspeed
	    popd >& /dev/null
	done
	start
}	


restart() {
	stop
	start
}	

reload() {
	trap "" SIGHUP
	killall -HUP $PROGNAME
}	

case "$1" in
start)
	start
	;;
low) 
    low
    ;;
high)
    high
    ;;
stop)
	stop
	;;
reload)
	reload
	;;
restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/$PROGNAME ]; then
	    restart
	fi
	;;
status)
	status $PROGNAME
	;;
*)
	INITNAME=`basename $0`
	gprintf "Usage: %s {start|stop|low|high|restart|condrestart|status}\n" "$INITNAME"
	exit 1
esac

exit $RETVAL