xref: /freebsd/libexec/rc/rc.d/moused (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
10696600cSBjoern A. Zeeb#!/bin/sh
20696600cSBjoern A. Zeeb#
30696600cSBjoern A. Zeeb#
40696600cSBjoern A. Zeeb
50696600cSBjoern A. Zeeb# PROVIDE: moused
60696600cSBjoern A. Zeeb# REQUIRE: DAEMON FILESYSTEMS
70696600cSBjoern A. Zeeb# KEYWORD: nojail shutdown
80696600cSBjoern A. Zeeb
90696600cSBjoern A. Zeeb. /etc/rc.subr
100696600cSBjoern A. Zeeb
110696600cSBjoern A. Zeebname="moused"
120696600cSBjoern A. Zeebdesc="Mouse daemon"
130696600cSBjoern A. Zeebrcvar="moused_enable"
140696600cSBjoern A. Zeebcommand="/usr/sbin/${name}"
150696600cSBjoern A. Zeebstart_cmd="moused_start"
160696600cSBjoern A. Zeebpidprefix="/var/run/moused"
170696600cSBjoern A. Zeebpidfile="${pidprefix}.pid"
180696600cSBjoern A. Zeebpidarg=
190696600cSBjoern A. Zeebload_rc_config $name
200696600cSBjoern A. Zeeb
21*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj: nojail keyword
22*f99f0ee1SAlexander Leidinger# XXX: How does moused communiacte with the kernel?
23*f99f0ee1SAlexander Leidinger# XXX: Does the kernel prevent this communcation in jails?
24*f99f0ee1SAlexander Leidingermoused_svcj="NO"
25*f99f0ee1SAlexander Leidinger
260696600cSBjoern A. Zeeb# Set the pid file and variable name. The second argument, if it exists, is
270696600cSBjoern A. Zeeb# expected to be the mouse device.
280696600cSBjoern A. Zeeb#
290696600cSBjoern A. Zeebif [ -n "$2" ]; then
300696600cSBjoern A. Zeeb	eval moused_$2_enable=\${moused_$2_enable-${moused_nondefault_enable}}
310696600cSBjoern A. Zeeb	rcvar="moused_${2}_enable"
320696600cSBjoern A. Zeeb	pidfile="${pidprefix}.$2.pid"
330696600cSBjoern A. Zeeb	pidarg="-I $pidfile"
340696600cSBjoern A. Zeebfi
350696600cSBjoern A. Zeeb
360696600cSBjoern A. Zeebmoused_start()
370696600cSBjoern A. Zeeb{
380696600cSBjoern A. Zeeb	local ms myflags myport mytype
390696600cSBjoern A. Zeeb
400696600cSBjoern A. Zeeb	# Set the mouse device and get any related variables. If
410696600cSBjoern A. Zeeb	# a moused device has been specified on the commandline, then
420696600cSBjoern A. Zeeb	# rc.conf(5) variables defined for that device take precedence
430696600cSBjoern A. Zeeb	# over the generic moused_* variables. The only exception is
440696600cSBjoern A. Zeeb	# the moused_port variable, which if not defined sets it to the
450696600cSBjoern A. Zeeb	# passed in device name.
460696600cSBjoern A. Zeeb	#
470696600cSBjoern A. Zeeb	ms=$1
480696600cSBjoern A. Zeeb	if [ -n "$ms" ]; then
490696600cSBjoern A. Zeeb		eval myflags=\${moused_${ms}_flags-$moused_flags}
500696600cSBjoern A. Zeeb		eval myport=\${moused_${ms}_port-/dev/$ms}
510696600cSBjoern A. Zeeb		eval mytype=\${moused_${ms}_type-$moused_type}
520696600cSBjoern A. Zeeb	else
530696600cSBjoern A. Zeeb		ms="default"
540696600cSBjoern A. Zeeb		myflags="$moused_flags"
550696600cSBjoern A. Zeeb		myport="$moused_port"
560696600cSBjoern A. Zeeb		mytype="$moused_type"
570696600cSBjoern A. Zeeb	fi
580696600cSBjoern A. Zeeb
59325ebf37SJose Luis Duran	startmsg -n "Starting ${ms} moused"
600696600cSBjoern A. Zeeb	/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
61325ebf37SJose Luis Duran	startmsg '.'
620696600cSBjoern A. Zeeb
630696600cSBjoern A. Zeeb	mousechar_arg=
640696600cSBjoern A. Zeeb	case ${mousechar_start} in
650696600cSBjoern A. Zeeb	[Nn][Oo] | '')
660696600cSBjoern A. Zeeb		;;
670696600cSBjoern A. Zeeb	*)
680696600cSBjoern A. Zeeb		mousechar_arg="-M ${mousechar_start}"
690696600cSBjoern A. Zeeb		;;
700696600cSBjoern A. Zeeb	esac
710696600cSBjoern A. Zeeb
720696600cSBjoern A. Zeeb	for ttyv in /dev/ttyv* ; do
730696600cSBjoern A. Zeeb		vidcontrol < ${ttyv} ${mousechar_arg} -m on
740696600cSBjoern A. Zeeb	done
750696600cSBjoern A. Zeeb}
760696600cSBjoern A. Zeeb
770696600cSBjoern A. Zeebrun_rc_command $*
78