#!/bin/sh
# $Id: pbbuttonsd.init,v 1.5 2005-12-08 01:02:49 glen Exp $
#
# pbbuttonsd:	Sets up pbuttonsd
#
# chkconfig:	2345 69 31
# description:	Daemon that handle the special hotkeys of an Apple iBook, Powerbook or TiBook
#
# config:	/etc/sysconfig/pbbutonsd

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

# Get service config
if [ -f /etc/sysconfig/pbbuttonsd ]; then
	. /etc/sysconfig/pbbuttonsd
fi

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Check if service is already running?
	if [ ! -f /var/lock/subsys/pbbuttonsd ]; then
		# try load event module
		modprobe evdev > /dev/null 2>&1
		msg_starting "pbbuttonsd"
		daemon pbbuttonsd $PB_FLAGS
		RETVAL=$?
		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pbbuttonsd
	else
		msg_already_running "pbbuttonsd"
	fi
	;;
  stop)
	if [ -f /var/lock/subsys/pbbuttonsd ]; then
		msg_stopping "pbbuttonsd"
		killproc pbbuttonsd
		rm -f /var/lock/subsys/pbbuttonsd >/dev/null 2>&1
	else
		msg_not_running pbbuttonsd
	fi
	;;
  status)
	status pbbuttonsd
	exit $?
	;;
  restart|force-reload)
	$0 stop
	$0 start
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit $RETVAL
