#!/bin/bash
#
# /etc/rc.d/init.d/cpufreqd
#
# cpufreqd      This shell script takes care of starting and stopping
#               the cpufreqd daemon.
#
# chkconfig: - 99 1
# description: cpufreqd is a front end for cpufreq speedstep control
# processname: cpufreqd
# config: /etc/cpufreqd.conf

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

RETVAL=0
PROG="cpufreqd"

if ! [ -x /sbin/$PROG ]
then
    echo "$0: /sbin/$PROG not found!"
    exit 1
fi
if ! [ -f /etc/$PROG.conf ]
then
    echo "$0: /etc/$PROG.conf not found!"
    exit 1
fi

start() {
        # Start daemon.
        echo -n $"Starting $PROG: "
        daemon /sbin/$PROG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROG
        return $RETVAL
}

stop() {
        # Stop daemon.
        echo -n $"Shutting down $PROG: "
        killproc $PROG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/$PROG ]
        then
            stop
            start
            RETVAL=$?
        fi

        ;;
  status)
        status $PROG
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $RETVAL