Skip to content

Instantly share code, notes, and snippets.

@twxia
Last active May 27, 2017 04:04
Show Gist options
  • Save twxia/e26784909ff5fb81c589 to your computer and use it in GitHub Desktop.
Save twxia/e26784909ff5fb81c589 to your computer and use it in GitHub Desktop.
NTUAF Monitor Project
#!/bin/sh
SESSION_NAME="mjpeg_relay"
cd mjpeg-relay
tmux has-session -t $SESSION_NAME
if [ $? != 0 ]
then
tmux new-session -s $SESSION_NAME -n one -d
tmux send-keys -t $SESSION_NAME "python relay.py -p 1001 -w 2001 http://140.112.91.176:8001/stream" C-m
tmux new-window -n two -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:1 "python relay.py -p 1002 -w 2002 http://140.112.91.176:8002/stream" C-m
tmux new-window -n three -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:2 "python relay.py -p 1003 -w 2003 http://140.112.91.176:8003/stream" C-m
tmux new-window -n four -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:3 "python relay.py -p 1004 -w 2004 http://140.112.91.176:8004/stream" C-m
tmux new-window -n five -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:4 "python relay.py -p 1005 -w 2005 http://140.112.91.176:8005/stream" C-m
tmux new-window -n six -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:5 "python relay.py -p 1006 -w 2006 http://140.112.91.176:8006/stream" C-m
tmux new-window -n seven -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:6 "python relay.py -p 1007 -w 2007 http://140.112.91.176:8007/stream" C-m
tmux new-window -n eight -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:7 "python relay.py -p 1008 -w 2008 http://140.112.91.176:8008/stream" C-m
tmux new-window -n nine -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:8 "python relay.py -p 1009 -w 2009 http://140.112.91.176:8009/stream" C-m
tmux new-window -n ten -t $SESSION_NAME
tmux send-keys -t $SESSION_NAME:9 "python relay.py -p 1010 -w 2010 http://140.112.91.176:8010/stream" C-m
fi
tmux attach -t $SESSION_NAME

NTUAF Monitor Project

architecture

mjpg_streamer

for example(get camera source then output to 8000 port with credentials):

mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8000 -c username:password"

Reference

  1. install nginx
opkg update
opkg install nginx
  1. go to edit nginx conf
vim /etc/nginx/nginx.conf

rewrite http block(replace listen(can also use 7777) and rewrite url)

server {                                                                  
  listen       7777;           #[here]port to redirect
  server_name  localhost;                                               
                                                                        
  #charset koi8-r;                                                      
                                                                        
  #access_log  logs/host.access.log  main;                              
                                                                        
  location / {                                                          
      rewrite ^ http://192.168.0.1/stream permanent;     #[here]redirect to http://192.168.0.1/stream (this is LAN ipcam)
  }

restart nginx

/etc/init.d/nginx restart
  1. ssh connection keep alive config
vim /etc/config/dropbear

add option SSHKeepAlive 60 to behind

  1. create tunnel script
vim /etc/init.d/tunnel-builder
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org

START=50

start() {
        ssh -NfR 7773:localhost:7777 [email protected] -i /root/nopass
}

ssh reverse tunnel description:

ssh -NfR [remote port to access local host's port]:localhost:7777 [email protected] -i /root/nopass

  • Figure out the controlable IO id: mjpg-streamer/mjpg-streamer-experimental/www/control.htm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment