Created
September 20, 2011 23:41
-
-
Save stesh/1230746 to your computer and use it in GitHub Desktop.
Keep a tunnel to a proxy server open on a dodgy shared Internet connection
This file contains hidden or 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
| #!/bin/bash | |
| connect() { | |
| ssh proxyserver -fN | |
| } | |
| disconnect() { | |
| kill -n 9 $(pgrep -f "ssh proxyserver -fN") 2>/dev/null | |
| } | |
| reconnect() { | |
| disconnect | |
| connect | |
| } | |
| is_disconnected() { | |
| nc -z localhost 5000 | |
| echo $? | |
| return $? | |
| } | |
| while true; do | |
| is_disconnected && reconnect | |
| sleep 5; | |
| done 1>/dev/null 2>/dev/null & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment