#!/bin/sh

load_configuration () {
  sed -e 's|#.*||; /^[ 	]*$/d; s|^|/usr/bin/cpufreq |' /etc/cpufreqd.conf | sh | grep -v '^OK$'
}

case "$1" in
start)
  if [ ! -r /etc/cpufreqd.conf ]; then
    exit 1
  fi
  /usr/sbin/cpufreqd
  load_configuration
  ;;

stop)
  killall cpufreqd
  ;;

restart)
  $0 stop
  $0 start
  ;;

reload)
  /usr/bin/cpufreq cond flush | grep -v '^OK$'
  load_configuration
  ;;

*)
  echo $0 'start|stop|restart|reload' >&2
  exit 1
esac
