[package] mjpg-streamer: install web pages (#6499)
[openwrt/svn-archive/archive.git] / multimedia / mjpg-streamer / files / mjpg-streamer.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2009-2012 OpenWrt.org
3
4 START=50
5
6 SERVICE_DAEMONIZE=1
7 SERVICE_WRITE_PID=1
8
9 PROG=/usr/bin/mjpg_streamer
10
11 error() {
12 echo "${initscript}:" "$@" 1>&2
13 }
14
15 section_enabled() {
16 config_get_bool enabled "$1" 'enabled' 0
17 [ $enabled -gt 0 ]
18 }
19
20 start_instance() {
21 local s="$1"
22
23 section_enabled "$s" || return 1
24
25 config_get device "$s" 'device'
26 config_get resolution "$s" 'resolution'
27 config_get fps "$s" 'fps'
28 config_get www "$s" 'www'
29 config_get port "$s" 'port'
30
31 [ -c "$device" ] || {
32 error "device '$device' does not exist"
33 return 1
34 }
35
36 service_start /usr/bin/mjpg_streamer --input "input_uvc.so \
37 --device $device --fps $fps --resolution $resolution" \
38 --output "output_http.so --www $www --port $port"
39 }
40
41 stop_instance() {
42 local s="$1"
43
44 section_enabled "$s" || return 1
45
46 service_stop /usr/bin/mjpg_streamer
47 }
48
49 start() {
50 config_load 'mjpg-streamer'
51 config_foreach start_instance 'mjpg-streamer'
52 }
53
54 stop() {
55 config_load 'mjpg-streamer'
56 config_foreach stop_instance 'mjpg-streamer'
57 }