Skip to content

Instantly share code, notes, and snippets.

@jmar71n
Created May 31, 2010 07:55
Show Gist options
  • Save jmar71n/419638 to your computer and use it in GitHub Desktop.
Save jmar71n/419638 to your computer and use it in GitHub Desktop.
#!/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