Last active
September 19, 2018 03:30
-
-
Save chenkaie/f161c8d35bd501f7076215beab0241bb to your computer and use it in GitHub Desktop.
UVC Watchdog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env expect | |
# Description: | |
# This tool aims to achieve the "auto-start script" upon device reboot or power lost, | |
# since there's no ready auto-start hook at post-init stage for UVC | |
# Installation: | |
# Install "expect", "netcat" and "sshpass" first if your Linux distribution don't have it ready | |
# $ sudo apt-get install expect sshpass netcat | |
set count 1; | |
while { $count > 0 } { | |
set timeout 30 | |
puts "[exec date], Run at $count-th time\n"; | |
spawn sshpass -p ubnt ssh -o ServerAliveInterval=60 -q [email protected] | |
send "uptime\r" | |
send "sleep 30; echo pushStream uri=rtmp://a.rtmp.youtube.com/live2/ localstreamname=s0 targetStreamName=xxxx-xxxx-xxxx-xxxx forceTcp=true | nc 127.0.0.1 1112 -w 1 -i 1\r" | |
interact timeout 300 { send "\x00" } | |
wait | |
set count [expr $count+1]; | |
sleep 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment