source: packages/multimedia/uvc-streamer/files/uvc-streamer.init @ 10127

Last change on this file since 10127 was 10127, checked in by olli, 8 years ago

[Packages] multimedia/uvc-streamer: Fix init script

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.1 KB
Line 
1#!/bin/sh /etc/rc.common
2# Copyright (C) 2007 OpenWrt.org
3START=50
4
5SSD=start-stop-daemon
6NAME=uvc_streamer
7PIDF=/var/run/$NAME.pid
8PROG=/sbin/$NAME
9
10append_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
19append_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
28start_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
39stop_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
45start() {
46        config_load "uvc-streamer"
47        config_foreach start_service "uvc-streamer"
48}
49
50stop() {
51        config_load "uvc-streamer"
52        config_foreach stop_service "uvc-streamer"
53}
Note: See TracBrowser for help on using the repository browser.