[packages] multimedia/uvc-streamer: Actually use the start-stop-daemon. Seems the...
[openwrt/svn-archive/archive.git] / multimedia / uvc-streamer / files / uvc-streamer.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2008 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 $SSD -K -p $PIDF
41 }
42
43 start() {
44 config_load "uvc-streamer"
45 config_foreach start_service "uvc-streamer"
46 }
47
48 stop() {
49 config_load "uvc-streamer"
50 config_foreach stop_service "uvc-streamer"
51 }