#!/bin/bash
#
# Init file for tp-scroll, IBM Trackpoint emulation
#
# Written by Dag Wieers <dag@wieers.com>.
#
# chkconfig: - 90 10
# description: IBM Trackpoint Emulation
#
# processname: tp-scroll
# config: /etc/sysconfig/tp-scroll
# pidfile: /var/run/tp-scroll

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

[ -x /usr/sbin/tp-scroll ] || exit 1
[ -r /etc/sysconfig/tp-scroll ] || exit 1

RETVAL=0
prog="tp-scroll"
desc="IBM Trackpoint emulation"

# Read configuration
if [ -r /etc/sysconfig/tp-scroll ]; then
	. /etc/sysconfig/tp-scroll
fi

start () {
	echo -n $"Starting $desc ($prog): "
	daemon $prog -i $INPUT_DEVICE -o $OUTPUT_DEVICE -x $XY_ACCEL_EXP -z $Z_ACCEL_EXP -m $Z_ACCEL_MULT &
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	return $RETVAL
}

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

restart(){
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
	restart
	;;
  condrestart)
	[ -e /var/lock/subsys/$prog ] && restart
	RETVAL=$?
	;;
  status)
	status $prog
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|condrestart|status}"
	RETVAL=1
esac

exit $RETVAL
