#!/bin/sh
#
# chkconfig: - 49 49
# pidfile: /var/run/btnx.pid
# config: /etc/btnx/btnx_config
# description: Mouse button rerouter daemon.
#
# Author: Ichiro Nakai <ichiro@n.email.ne.jp>
#

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

RETVAL=0

# See how we were called.
case "$1" in
  start)
	# Start daemon.
	echo -n "Starting btnx: "
        # Run btnx.
        daemon /usr/sbin/btnx -b
	RETVAL=$?
	echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/btnx
	;;
  stop)
	# Stop daemon.
	echo -n "Shutting down btnx: "
	killproc btnx
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/btnx
	;;
  restart)
        $0 stop
        $0 start
	RETVAL=$?
        ;;
  status)
	status btnx
	RETVAL=$?
	;;
  *)
	echo "Usage: btnx {start|stop|restart|status}"
	exit 1
esac

exit 0
