Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# |
3 |
# $FreeBSD$ |
4 |
# |
5 |
# PROVIDE: cx88d |
6 |
# REQUIRE: LOGIN |
7 |
# KEYWORD: shutdown |
8 |
# |
9 |
# Add the following line to /etc/rc.conf[.local] to enable cx88d |
10 |
# |
11 |
# cx88d_enable (bool): Set to "NO" by default. |
12 |
# Set it to "YES" to enable cx88d. |
13 |
# cx88d_args (str): Extra arguments to be passed to all cx88 instances (default "-p 0 -q -h -u dvb://") |
14 |
# cx88d_devs (str): Whitespace-delimited list of devices on which |
15 |
# to enable DVB capture (e.g. cx88d_devs="cx88mpeg0 cx88mpeg2"). |
16 |
# Defaults to all cx88mpeg devices under /dev. |
17 |
# cx88d_{dev}_args (str) Extra arguments to be passed to cx88 instance for specific device |
18 |
# (e.g. cx88d_cx88mpeg1_args="-u udp://127.0.0.1:8802") (default empty) |
19 |
# |
20 |
|
21 |
. /etc/rc.subr |
22 |
|
23 |
name="cx88d" |
24 |
rcvar=cx88d_enable |
25 |
|
26 |
load_rc_config $name |
27 |
|
28 |
: ${cx88d_enable:="NO"} |
29 |
: ${cx88d_args="-p 0 -q -h -u dvb://"} |
30 |
|
31 |
procname="%%PREFIX%%/bin/cx88" |
32 |
command="/usr/sbin/daemon" |
33 |
|
34 |
cx88d_showports() { |
35 |
printf "PORT\tCMMMAND\n" |
36 |
sockstat -l -P tcp | grep cx88 | while read line; do |
37 |
command="" |
38 |
port="" |
39 |
for field in $line; do |
40 |
if [ `expr "$field" : "[0-9]*"` -gt 0 -a "$command" = "" ]; then |
41 |
command=`ps -o command= -p $field` |
42 |
elif [ `expr "$field" : "\*:[0-9]*"` -gt 2 -a "$port" = "" ]; then |
43 |
port=`echo $field | cut -c 3-` |
44 |
fi |
45 |
done |
46 |
printf "$port\t$command\n" |
47 |
done |
48 |
} |
49 |
|
50 |
extra_commands="showports" |
51 |
showports_cmd="${name}_showports" |
52 |
|
53 |
case $1 in |
54 |
*showports) |
55 |
run_rc_command "$1" |
56 |
;; |
57 |
*rcvar) |
58 |
run_rc_command "$1" |
59 |
;; |
60 |
*) |
61 |
if [ -z "${cx88d_devs}" ]; then |
62 |
cx88d_devs=`ls /dev/cx88mpeg* | cut -c 6-` |
63 |
fi |
64 |
for devnode in ${cx88d_devs}; do |
65 |
pidfile="/var/run/cx88d.${devnode}.pid" |
66 |
eval cx88d_instance_flags=\$cx88d_${devnode}_args |
67 |
command_args="-fp ${pidfile} ${procname} -d /dev/${devnode} ${cx88d_args} ${cx88d_instance_flags}" |
68 |
run_rc_command "$1" |
69 |
done |
70 |
;; |
71 |
esac |
72 |
|