proper cli
This commit is contained in:
@@ -119,13 +119,23 @@ function read_config() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run_args() {
|
function run_args() {
|
||||||
HOST="$1"
|
if [[ -z "$2" ]]; then
|
||||||
LOCAL="$2"
|
# only hostname
|
||||||
REMOTE="$3"
|
if grep -q "^$1:" "$CONF"; then
|
||||||
[[ -z "$REMOTE" ]] && REMOTE="$LOCAL"
|
grep "^$1:" "$CONF"
|
||||||
echo Connect to $HOST
|
switches=$( grep "^$1:" "$CONF" | parse_switches )
|
||||||
switches=$( echo '-L "${LOCAL}:localhost:${REMOTE}" "$HOST"' | $BASE )
|
else
|
||||||
run_command "$switches"
|
echo No such host
|
||||||
|
cat "$CONF"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
host="$1"
|
||||||
|
shift 1
|
||||||
|
switches=$( echo "$host: $@" | parse_switches )
|
||||||
|
fi
|
||||||
|
eval "ssh -f -n $switches \"nice /bin/bash -c 'for ((i=1;i<$MAGIC_TIME;i++)); do cut -f4 -d \\\" \\\" /proc/\\\$PPID/stat | xargs kill -0 || exit ; sleep 60;done'; echo tunnelier $1\""
|
||||||
|
exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_command() {
|
function run_command() {
|
||||||
@@ -153,13 +163,14 @@ function instant_entry() {
|
|||||||
read -e -i "$REMOTE" LOCAL
|
read -e -i "$REMOTE" LOCAL
|
||||||
test -z "$LOCAL" && return
|
test -z "$LOCAL" && return
|
||||||
printf "${colRow}-L ${LOCAL}:localhost:${REMOTE} ${HOST}${colZ}\n"
|
printf "${colRow}-L ${LOCAL}:localhost:${REMOTE} ${HOST}${colZ}\n"
|
||||||
run_args "$HOST" "$LOCAL" "$REMOTE"
|
run_args "$HOST" "$LOCAL:$REMOTE"
|
||||||
printf "${colMenu}See the connection in 'list ssh'${colZ}\n"
|
printf "${colMenu}See the connection in 'list ssh'${colZ}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ -n "$2" ]] && {
|
if [[ -n "$1" ]]; then
|
||||||
run_args "$@"
|
run_args "$@"
|
||||||
}
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
ids=()
|
ids=()
|
||||||
|
|||||||
Reference in New Issue
Block a user