Created
September 8, 2015 11:52
-
-
Save augcesar/c4e2c37d21e26a13502f 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 | |
# [connect_proxy.sh] | |
### VAR ### | |
HOST_USER="[email protected]" | |
HOST_SOURCE="172.19.5.10" | |
PORT="9876" | |
PORT_SSH="22" | |
### VAR ### | |
function usage | |
{ | |
echo "uso: connect_proxy.sh [-r run] [-h ajuda]" | |
} | |
function run | |
{ | |
echo "..." | |
while (true) do | |
if [[ $(ss -tpa | grep $PORT | grep ssh) != *ssh* ]]; then | |
$(ssh -f $HOST_USER -D $HOST_SOURCE:$PORT -N -p $PORT_SSH) | |
fi | |
sleep 5 | |
done | |
} | |
while [ "$1" != "" ]; do | |
case $1 in | |
-r | --run ) run ;; | |
-h | --ajuda ) usage; exit ;; | |
* ) ;; | |
esac | |
shift | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment