LazaroFilm

mainsail-stream.sh

Sep 22nd, 2020 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #!/bin/sh
  2. # /etc/init.d/mainsail-stream.sh
  3. ### BEGIN INIT INFO
  4. # Provides: mainsail-stream.sh
  5. # Required-Start: $network
  6. # Required-Stop: $network
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: mjpg_streamer for webcam
  10. # Description: Streams /dev/video0 to http://IP/?action=stream
  11. ### END INIT INFO
  12. f_message(){
  13. echo "[+] $1"
  14. }
  15.  
  16. # Carry out specific functions when asked to by the system
  17. case "$1" in
  18. start)
  19. f_message "Starting mjpg_streamer"
  20. /usr/local/bin/mjpg_streamer -b -i "input_raspicam.so -fps 15 -x 1640 -y 922" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"-b
  21. sleep 2
  22. f_message "mjpg_streamer started"
  23. ;;
  24. stop)
  25. f_message "Stopping mjpg_streamer…"
  26. killall mjpg_streamer
  27. f_message "mjpg_streamer stopped"
  28. ;;
  29. restart)
  30. f_message "Restarting daemon: mjpg_streamer"
  31. killall mjpg_streamer
  32. /usr/local/bin/mjpg_streamer -b -i "input_raspicam.so -fps 15 -x 1640 -y 922 -preview" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"
  33. sleep 2
  34. f_message "Restarted daemon: mjpg_streamer"
  35. ;;
  36. status)
  37. pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk ‘{print $1}’ | head -n 1`
  38. if [ -n "$pid" ];
  39. then
  40. f_message "mjpg_streamer is running with pid ${pid}"
  41. f_message "mjpg_streamer was started with the following command line"
  42. cat /proc/${pid}/cmdline ; echo ""
  43. else
  44. f_message "Could not find mjpg_streamer running"
  45. fi
  46. ;;
  47. *)
  48. f_message "Usage: $0 {start|stop|status|restart}"
  49. exit 1
  50. ;;
  51. esac
  52. exit 0
Add Comment
Please, Sign In to add comment