#!/bin/sh
# $Id: gpm.init,v 1.2 2002/05/28 19:13:51 nico Exp $
#
# chkconfig: 2345 85 15
# description: \
#	gpm provides mouse support to text-based Linux applications as \
#	well as console cut-and-paste operations using the mouse.
#
# processname: gpm
# pidfile: /var/run/gpm.pid
# config: /etc/sysconfig/mouse

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

OWL_STARTUP_ENABLE=1

MOUSECFG=/etc/sysconfig/mouse

case "$1" in
start)
	if [ -f "$MOUSECFG" ]; then
		. "$MOUSECFG"
	else
		MOUSETYPE="none"
	fi

	if [ "$MOUSETYPE" = "none" ]; then
		echo "Not starting gpm (no mouse is configured)"
		exit 0
	fi

	if [ "$MOUSETYPE" = "Microsoft" ]; then
		MOUSETYPE=ms
	fi

	if [ -n "$MOUSETYPE" ]; then
		GPM_ARG="-t $MOUSETYPE"
	else
		GPM_ARG=""
	fi

	if [ "0$OWL_STARTUP_VERSION" -ge 3 ]; then
		daemon --pidfile /var/run/gpm.pid --expect-user root \
			-- gpm "$GPM_ARG"
	else
		daemon gpm "$GPM_ARG"
	fi
	;;
stop)
	if [ "0$OWL_STARTUP_VERSION" -ge 3 ]; then
		killproc --pidfile /var/run/gpm.pid --expect-user root gpm
	else
		killproc gpm
	fi
	;;
restart|reload)
	$0 stop
	$0 start
	;;
status)
	status --pidfile /var/run/gpm.pid --expect-user root gpm
	;;
*)
	echo "Usage: gpm {start|stop|restart|status}"
	exit 1
esac

exit $?
