packages: forgot an updated bluez-utils patch
[openwrt/svn-archive/archive.git] / multimedia / uvc-streamer / files / uvc-streamer.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007 OpenWrt.org
3 START=50
4
5 SSD=start-stop-daemon
6 NAME=uvc_streamer
7 PIDF=/var/run/$NAME.pid
8 PROG=/sbin/$NAME
9
10 append_bool() {
11 local section="$1"
12 local option="$2"
13 local value="$3"
14 local _val
15 config_get_bool _val "$section" "$option" '0'
16 [ "$_val" -gt 0 ] && append args "$3"
17 }
18
19 append_string() {
20 local section="$1"
21 local option="$2"
22 local value="$3"
23 local _val
24 config_get _val "$section" "$option"
25 [ -n "$_val" ] && append args "$3 $_val"
26 }
27
28 start_service() {
29 local section="$1"
30 args=""
31 append_string "$section" device "-d"
32 append_string "$section" resolution "-r"
33 append_bool "$section" framespersecond "-f"
34 append_string "$section" port "-p"
35 config_get_bool "enabled" "$section" "enabled" '1'
36 [ "$enabled" -gt 0 ] && sleep 5s && $SSD -S -p $PIDF -q -x $PROG -- -b $args &
37 }
38
39 stop_service() {
40 killall $NAME 2>&1 > /dev/null
41 # FIXME: Fix Busybox start-stop-daemon to work with multiple PIDs
42 # $SSD -K -p $PIDF -q
43 }
44
45 start() {
46 config_load "uvc-streamer"
47 config_foreach start_service "uvc-streamer"
48 }
49
50 stop() {
51 config_load "uvc-streamer"
52 config_foreach stop_service "uvc-streamer"
53 }