moused revision 230099
11844Swollman#!/bin/sh
234087Sbde#
31638Srgrimes# $FreeBSD: head/etc/rc.d/moused 230099 2012-01-14 02:18:41Z dougb $
41844Swollman#
51638Srgrimes
61638Srgrimes# PROVIDE: moused
71638Srgrimes# REQUIRE: DAEMON cleanvar
829129Speter# KEYWORD: nojail shutdown
929129Speter
1029129Speter. /etc/rc.subr
111844Swollman
121638Srgrimesname="moused"
132827Sjkhrcvar="moused_enable"
141844Swollmancommand="/usr/sbin/${name}"
151844Swollmanstart_cmd="moused_start"
1626051Sasamipidprefix="/var/run/moused"
171844Swollmanpidfile="${pidprefix}.pid"
181638Srgrimespidarg=
192827Sjkhload_rc_config $name
201638Srgrimes
212827Sjkh# Set the pid file and variable name. The second argument, if it exists, is
221638Srgrimes# expected to be the mouse device.
2327028Spst#
241844Swollmanif [ -n "$2" ]; then
251844Swollman	eval moused_$2_enable=\${moused_$2_enable-${moused_nondefault_enable}}
261638Srgrimes	rcvar="moused_${2}_enable"
271638Srgrimes	pidfile="${pidprefix}.$2.pid"
281638Srgrimes	pidarg="-I $pidfile"
291638Srgrimesfi
301844Swollman
311638Srgrimesmoused_start()
3234081Sbde{
331844Swollman	local ms myflags myport mytype
341844Swollman
358321Sbde	# Set the mouse device and get any related variables. If
361844Swollman	# a moused device has been specified on the commandline, then
3733624Seivind	# rc.conf(5) variables defined for that device take precedence
382351Sbde	# over the generic moused_* variables. The only exception is
391638Srgrimes	# the moused_port variable, which if not defined sets it to the
402351Sbde	# passed in device name.
412351Sbde	#
422351Sbde	ms=$1
432351Sbde	if [ -n "$ms" ]; then
442351Sbde		eval myflags=\${moused_${ms}_flags-$moused_flags}
452351Sbde		eval myport=\${moused_${ms}_port-/dev/$ms}
4633624Seivind		eval mytype=\${moused_${ms}_type-$moused_type}
4734081Sbde	else
482351Sbde		ms="default"
4933624Seivind		myflags="$moused_flags"
501638Srgrimes		myport="$moused_port"
511638Srgrimes		mytype="$moused_type"
521638Srgrimes	fi
531638Srgrimes
541638Srgrimes	check_startmsgs && echo -n "Starting ${ms} moused"
551638Srgrimes	/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
561844Swollman	check_startmsgs && echo '.'
571638Srgrimes
581638Srgrimes	mousechar_arg=
591638Srgrimes	case ${mousechar_start} in
601638Srgrimes	[Nn][Oo] | '')
6118340Sswallace		;;
621638Srgrimes	*)
6333816Sbde		mousechar_arg="-M ${mousechar_start}"
641638Srgrimes		;;
6527910Sasami	esac
6624750Sbde
6728945Speter	for ttyv in /dev/ttyv* ; do
6824750Sbde		vidcontrol < ${ttyv} ${mousechar_arg} -m on
6925110Sbde	done
7028945Speter}
7131810Sbde
7228945Speterrun_rc_command $*
7324750Sbde