Skip to content

Instantly share code, notes, and snippets.

@chenkaie
Created August 30, 2016 14:50
Show Gist options
  • Save chenkaie/42e592f24ebe50f11c1346efbde1a544 to your computer and use it in GitHub Desktop.
Save chenkaie/42e592f24ebe50f11c1346efbde1a544 to your computer and use it in GitHub Desktop.
UVC RTMP Service Watchdog
#!/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 createService ip=0.0.0.0 port=1935 protocol=inboundRtmp | 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