#! /bin/sh
#
# pmud	       Power Manager daemon for Apple powerbooks
#
# chkconfig: 2345 40 60
# description: pmud is a daemon which periodically polls the PMU \
#              (power manager) and performs functions such as enabling \
#              or disabling devices appropriately when the power source \
#              changes.
# processname: pmud
# config: /etc/powerlevels
# pidfile: /var/run/pmud.pid

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

# Source power daemon options
[ -f /etc/sysconfig/power ] && . /etc/sysconfig/power

# If the machine is not a laptop, bail out elegantly.
MACHINE=`cat /proc/cpuinfo | grep machine | awk '{print $3}' | grep Book`

if [ -z "$MACHINE" ]; then
        gprintf "Bypassing pmud daemon, not a laptop: "
        echo
        exit 0
fi

# See how we were called.
case "$1" in
  start)
	gprintf "Starting pmud daemon: "
	daemon pmud $PMUD_FLAGS
	echo
	touch /var/lock/subsys/pmud
	;;
  stop)
	gprintf "Stopping pmud daemon: "
	killproc pmud
	echo
	rm -f /var/lock/subsys/pmud
	;;
  reload)
        $0 start
        ;;
  status)
	status pmud
	;;
  *)
	gprintf "Usage: pmud {start|stop|reload|status}\n"
	exit 1
esac

exit 0
