Bez popisu

mjpg-streamer.init 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2013 OpenWrt.org
  3. START=90
  4. STOP=10
  5. USE_PROCD=1
  6. PROG=/usr/bin/mjpg_streamer
  7. error() {
  8. echo "${initscript}:" "$@" 1>&2
  9. }
  10. start_instance() {
  11. local s="$1"
  12. config_get_bool enabled "$1" 'enabled' 0
  13. [ $enabled -eq 0 ] && return
  14. config_get input "$s" 'input'
  15. if [ -z "$input" ]; then
  16. error "in section '$s' option input is missing"
  17. return 1
  18. fi
  19. config_get output "$s" 'output'
  20. if [ -z "$output" ]; then
  21. error "in section '$s' option output is missing"
  22. return 1
  23. fi
  24. local input_arg
  25. if [ "x$input" = 'xuvc' ]; then
  26. input_arg="input_uvc.so"
  27. config_get device "$s" 'device'
  28. if [ ! -c "$device" ]; then
  29. error "device '$device' does not exist"
  30. return 1
  31. fi
  32. input_arg="${input_arg} --device $device"
  33. config_get fps "$s" 'fps'
  34. [ -n "$fps" ] && input_arg="${input_arg} --fps $fps"
  35. config_get resolution "$s" 'resolution'
  36. [ -n "$resolution" ] && input_arg="${input_arg} --resolution $resolution"
  37. fi
  38. if [ -z "$input_arg" ]; then
  39. error "unsuported input option '$input' in section '$s'"
  40. return 1
  41. fi
  42. local output_arg
  43. if [ "x$output" = 'xhttp' ]; then
  44. output_arg="output_http.so"
  45. config_get port "$s" 'port'
  46. [ -n "$port" ] && output_arg="${output_arg} --port $port"
  47. config_get www "$s" 'www'
  48. [ -n "$www" ] && output_arg="${output_arg} --www $www"
  49. fi
  50. if [ -z "$output_arg" ]; then
  51. error "unsuported output option '$output' in section '$s'"
  52. return 1
  53. fi
  54. procd_open_instance
  55. procd_set_param command "$PROG" --input "$input_arg" --output "$output_arg"
  56. procd_close_instance
  57. }
  58. start_service() {
  59. config_load 'mjpg-streamer'
  60. config_foreach start_instance 'mjpg-streamer'
  61. }
  62. service_triggers() {
  63. procd_add_reload_trigger 'mjpg-streamer'
  64. }