From 18c6ebbbe04735628ee776e1c370ba1123649aa2 Mon Sep 17 00:00:00 2001 From: q Date: Sat, 19 Aug 2017 16:53:35 +0300 Subject: [PATCH] tunnelier command --- web/ssh-tunnelier | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/web/ssh-tunnelier b/web/ssh-tunnelier index 3a86766..cd158ef 100755 --- a/web/ssh-tunnelier +++ b/web/ssh-tunnelier @@ -11,6 +11,11 @@ to kill existing ssh processes. You don't need to keep the program on to remember connected sessions. Configuration stored in: $CONF + +If run with arguments, runs an ssh tunnel with arguments: + ssh-tunnelier hostname [local-port] remote-port + +If local port missing, the same port assumed in local " exit 0 } @@ -20,7 +25,6 @@ for (( i=1; i<=$#; i++ )); do [[ ${!i} = "--help" ]] && _helpexit done - [[ -f "$CONF" ]] || { echo No config file. echo "$CONF" each line like: @@ -82,10 +86,24 @@ function read_config() { done < <( grep -v ^# "$CONF" | grep '[a-zA-Z]' ) } +function run_args() { + HOST="$1" + LOCAL="$2" + REMOTE="$3" + [[ -z "$REMOTE" ]] && REMOTE="$LOCAL" + echo Connect to $HOST + ssh -f -n -L "${LOCAL}:localhost:${REMOTE}" "$HOST" "sleep $MAGIC_TIME" +} + function run_command() { eval $( get_command "$1" ) } + +[[ -n "$2" ]] && { + run_args "$@" +} + while true; do ids=() i=1