summaryrefslogtreecommitdiff
path: root/sysutils/uhidd/files/uhidd.in
blob: cbd052d53ce15b896b4bd515ff50b90d79c53507 (plain) (blame)
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
#!/bin/sh

# 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 $*