xref: /freebsd/libexec/rc/rc.d/msconvd (revision aef807876c305587c60f73e2cd914115d22a53fd)
1*aef80787SVladimir Kondratyev#!/bin/sh
2*aef80787SVladimir Kondratyev#
3*aef80787SVladimir Kondratyev#
4*aef80787SVladimir Kondratyev
5*aef80787SVladimir Kondratyev# PROVIDE: msconvd
6*aef80787SVladimir Kondratyev# REQUIRE: DAEMON FILESYSTEMS
7*aef80787SVladimir Kondratyev# KEYWORD: nojail shutdown
8*aef80787SVladimir Kondratyev
9*aef80787SVladimir Kondratyev. /etc/rc.subr
10*aef80787SVladimir Kondratyev
11*aef80787SVladimir Kondratyevname="msconvd"
12*aef80787SVladimir Kondratyevdesc="Mouse protocol conversion daemon"
13*aef80787SVladimir Kondratyevcommand="/usr/sbin/${name}"
14*aef80787SVladimir Kondratyevstart_cmd="msconvd_start"
15*aef80787SVladimir Kondratyevpidprefix="/var/run/msconvd"
16*aef80787SVladimir Kondratyevload_rc_config $name
17*aef80787SVladimir Kondratyev
18*aef80787SVladimir Kondratyev: ${msconvd_enable="NO"}
19*aef80787SVladimir Kondratyev: ${msconvd_type="auto"}
20*aef80787SVladimir Kondratyev
21*aef80787SVladimir Kondratyev# doesn't make sense to run in a svcj: nojail keyword
22*aef80787SVladimir Kondratyev# XXX: How does msconvd communiacte with the kernel?
23*aef80787SVladimir Kondratyev# XXX: Does the kernel prevent this communcation in jails?
24*aef80787SVladimir Kondratyevmsconvd_svcj="NO"
25*aef80787SVladimir Kondratyev
26*aef80787SVladimir Kondratyev# Set the pid file and variable name. The second argument, if it exists, is
27*aef80787SVladimir Kondratyev# expected to be the mouse device.
28*aef80787SVladimir Kondratyev#
29*aef80787SVladimir Kondratyevif [ -n "$2" ]; then
30*aef80787SVladimir Kondratyev	eval msconvd_$2_enable=\${msconvd_$2_enable-${msconvd_enable}}
31*aef80787SVladimir Kondratyev	rcvar="msconvd_$2_enable"
32*aef80787SVladimir Kondratyev	pidfile="${pidprefix}.$2.pid"
33*aef80787SVladimir Kondratyevelse
34*aef80787SVladimir Kondratyev	for ms in ${msconvd_ports}; do
35*aef80787SVladimir Kondratyev		/etc/rc.d/msconvd $1 ${ms}
36*aef80787SVladimir Kondratyev	done
37*aef80787SVladimir Kondratyev	exit 0
38*aef80787SVladimir Kondratyevfi
39*aef80787SVladimir Kondratyev
40*aef80787SVladimir Kondratyevmsconvd_start()
41*aef80787SVladimir Kondratyev{
42*aef80787SVladimir Kondratyev	local ms myflags myport mytype
43*aef80787SVladimir Kondratyev
44*aef80787SVladimir Kondratyev	# Set the mouse device and get any related variables. If
45*aef80787SVladimir Kondratyev	# a msconvd device has been specified on the commandline, then
46*aef80787SVladimir Kondratyev	# rc.conf(5) variables defined for that device take precedence
47*aef80787SVladimir Kondratyev	# over the generic msconvd_* variables. The only exception is
48*aef80787SVladimir Kondratyev	# the msconvd_port variable, which if not defined sets it to
49*aef80787SVladimir Kondratyev	# the passed in device name.
50*aef80787SVladimir Kondratyev	#
51*aef80787SVladimir Kondratyev	ms=$1
52*aef80787SVladimir Kondratyev	eval myflags=\${msconvd_${ms}_flags-$msconvd_flags}
53*aef80787SVladimir Kondratyev	eval myport=\${msconvd_${ms}_port-/dev/${ms}}
54*aef80787SVladimir Kondratyev	eval mytype=\${msconvd_${ms}_type-$msconvd_type}
55*aef80787SVladimir Kondratyev
56*aef80787SVladimir Kondratyev	startmsg -n "Starting ${ms} ${name}"
57*aef80787SVladimir Kondratyev	${command} ${myflags} -p ${myport} -t ${mytype} -I ${pidfile}
58*aef80787SVladimir Kondratyev	startmsg '.'
59*aef80787SVladimir Kondratyev}
60*aef80787SVladimir Kondratyev
61*aef80787SVladimir Kondratyevrun_rc_command $*
62