Created
May 31, 2010 07:55
-
-
Save jmar71n/419638 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
## Usage: ./socks-retry server.example.com | |
## Use key authentication | |
# ----------------------------- ssh Options ------------------------------------------------ | |
PORT=2048 | |
# -------------------- Shouldn't need to change anything bellow ------------------------------- | |
# Trap interrupts and exit instead of continuing the loop | |
trap "echo Ctl+C Detected... Exiting!; exit;" SIGINT SIGTERM | |
SSH="/usr/bin/ssh" | |
WGET="/usr/bin/wget" | |
# Set the initial exit value to failure | |
false | |
while [ $? -ne 0 ]; do | |
echo | |
echo "Checking Internet connection..." | |
false | |
until [ $? -eq 0 ]; do | |
$WGET -q --tries=10 --timeout=5 http://www.google.com -O /tmp/index.google &> /dev/null | |
done | |
$SSH -xNv -D $PORT -o "ServerAliveInterval 2" $1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment