#! /bin/sh
#
# chkconfig: 2345 99 01
# description: The pbbuttonsd is a daemon to control the special hotkeys \
#              of an Apple iBook, PowerBook or TiBook working as expected.
# processname: pbbuttonsd

# Get functions
. /etc/init.d/functions

start() {
 	echo -n "Starting pbbuttonsd: "
	pbbuttonsd -d
	RETVAL=$?
	echo
	if [ $RETVAL -eq 0 ] ; then
		touch /var/lock/subsys/pbbuttonsd
		return 0
	else
		return $RETVAL
	fi
}

stop() {
	echo -n "Stopping pbbuttonsd: "
	killproc pbbuttonsd
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pbbuttonsd
	return $RETVAL
}	

restart() {
	stop
	start
}	

# See how we were called.
case "$1" in
 start)
 	start
	;;
 stop)
 	stop
	;;
 status)
 	status pbbuttonsd
	;;
 restart)
 	restart
	;;
 *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
	;;
esac

exit $?
