proper cli
This commit is contained in:
@@ -119,13 +119,23 @@ function read_config() {
|
||||
}
|
||||
|
||||
function run_args() {
|
||||
HOST="$1"
|
||||
LOCAL="$2"
|
||||
REMOTE="$3"
|
||||
[[ -z "$REMOTE" ]] && REMOTE="$LOCAL"
|
||||
echo Connect to $HOST
|
||||
switches=$( echo '-L "${LOCAL}:localhost:${REMOTE}" "$HOST"' | $BASE )
|
||||
run_command "$switches"
|
||||
if [[ -z "$2" ]]; then
|
||||
# only hostname
|
||||
if grep -q "^$1:" "$CONF"; then
|
||||
grep "^$1:" "$CONF"
|
||||
switches=$( grep "^$1:" "$CONF" | parse_switches )
|
||||
else
|
||||
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() {
|
||||
@@ -153,13 +163,14 @@ function instant_entry() {
|
||||
read -e -i "$REMOTE" LOCAL
|
||||
test -z "$LOCAL" && return
|
||||
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"
|
||||
}
|
||||
|
||||
[[ -n "$2" ]] && {
|
||||
if [[ -n "$1" ]]; then
|
||||
run_args "$@"
|
||||
}
|
||||
exit $?
|
||||
fi
|
||||
|
||||
while true; do
|
||||
ids=()
|
||||
|
||||
Reference in New Issue
Block a user