-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlivestream.sh
64 lines (60 loc) · 2.36 KB
/
livestream.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# https://krystof.io/mjpg-streamer-on-a-raspberry-pi-zero-w-with-a-usb-webcam-streaming-setup/
# nouyang - my settings are 15 fps 640x480
# sudo service livestream status
# sudo service livestream restart
# http://raspberrypi.local:8080/?action=stream
# Enble on startup: (Note: does work, have patience waiting for server to
# come online)
# sudo chmod 755 /etc/init.d/livestream.sh
# sudo update-rc.d livestream.sh defaults
#!/bin/sh
# /etc/init.d/livestream.sh
### BEGIN INIT INFO
# Provides: livestream.sh
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mjpg_streamer for webcam
# Description: Streams /dev/video0 to http://IP/?action=stream
### END INIT INFO
f_message(){
echo "[+] $1"
}
# Carry out specific functions when asked to by the system
case "$1" in
start)
f_message "Starting mjpg_streamer"
/usr/local/bin/mjpg_streamer -b -i "input_uvc.so -f 15 -r 640x480" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"-b
sleep 2
f_message "mjpg_streamer started"
;;
stop)
f_message "Stopping mjpg_streamer…"
killall mjpg_streamer
f_message "mjpg_streamer stopped"
;;
restart)
f_message "Restarting daemon: mjpg_streamer"
killall mjpg_streamer
/usr/local/bin/mjpg_streamer -b -i "input_uvc.so -f 15 -r 640x480" -o "output_http.so -w /usr/local/share/mjpg-streamer/www"
sleep 2
f_message "Restarted daemon: mjpg_streamer"
;;
status)
pid=`ps -A | grep mjpg_streamer | grep -v "grep" | grep -v mjpg_streamer. | awk ‘{print $1}’ | head -n 1`
if [ -n "$pid" ];
then
f_message "mjpg_streamer is running with pid ${pid}"
f_message "mjpg_streamer was started with the following command line"
cat /proc/${pid}/cmdline ; echo ""
else
f_message "Could not find mjpg_streamer running"
fi
;;
*)
f_message "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0