summaryrefslogtreecommitdiff
path: root/sysutils/uhidd/files/uhidd.in
blob: a1e9c208bd838ca0e1833c23937e4699d4fce9c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: uhidd
# REQUIRE: DAEMON cleanvar
# KEYWORD: nojail shutdown

# Usage:
#	uhidd start ugenX.Y	# start uhidd on device 'ugenX.Y'
#	uhidd stop ugenX.Y	# stop uhidd on device 'ugenX.Y'
#	uhidd start		# start uhidd on all ugen device.
#	uhidd stop		# stop all uhidd instances.

. /etc/rc.subr

name=uhidd
rcvar=uhidd_enable

load_rc_config $name

: ${uhidd_enable:=NO}

command=%%PREFIX%%/sbin/${name}
start_cmd=uhidd_start
required_modules=vkbd
pidprefix=/var/run/uhidd
pidfile=${2+$pidprefix.`basename $2`.pid}

uhidd_start()
{
	local dev pf

	if [ -n "$1" ]; then
		${command} ${uhidd_flags} $1
	else
		for dev in /dev/ugen*; do
			pf="${pidprefix}.`basename ${dev}`.pid"
			if [ ! -f ${pf} ]; then
				${command} ${uhidd_flags} ${dev}
			fi
		done
	fi
}

run_rc_command $*