Add -u option to ssh to moblab by name.
- example usage
$ moblab_tunnel.sh -u moblab4
Checking tunnels for moblab4
moblab4 UI Tunnel http://localhost:9084 to 100.107.195.217
Checking tunnel with: ssh -S
/usr/local/google/home/dchan/.ssh/connections/moblab-sock-9084-80 -O
check moblab@100.107.195.217
Master running (pid=25287)
moblab4 Admin Tunnel http://localhost:9994 to 100.107.195.217
Checking tunnel with: ssh -S
/usr/local/google/home/dchan/.ssh/connections/moblab-sock-9994-9991
-O check moblab@100.107.195.217
Connecting to moblab4 with IP 100.107.195.217
localhost ~ #
BUG=None
TEST=Manually from desktop.
Change-Id: I634133e228d56ace6bdbe2834f28c72628d2e911
Reviewed-on: https://chromium-review.googlesource.com/424962
Reviewed-by: Tyler Reid <twreid@chromium.org>
Reviewed-by: Katherine Threlkeld <kathrelkeld@chromium.org>
Tested-by: danny chan <dchan@chromium.org>
diff --git a/provingground/firmware/moblab_tunnel.sh b/provingground/firmware/moblab_tunnel.sh
index d949d46..132070c 100755
--- a/provingground/firmware/moblab_tunnel.sh
+++ b/provingground/firmware/moblab_tunnel.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
@@ -63,7 +63,7 @@
mkdir -p "$SOCKET_DIR"
if [[ -z "$1" ]] || [[ "$1" == "all" ]]; then
- for i in {1..7}; do
+ for i in $(eval echo {1..${#MOBLABS[@]}}); do
mobs+=("moblab$i")
done
else
@@ -90,9 +90,19 @@
echo "Checking tunnels for ${mobs[*]}"
for moblab in "${mobs[@]}"; do
index=${moblab: -1}
+ echo "$moblab UI Tunnel http://localhost:$BASE_PORT$index to ${MOBLABS[$moblab]}"
check_tunnel "$BASE_PORT$index" 80 "${MOBLABS[$moblab]}"
+ echo "$moblab Admin Tunnel http://localhost:$BASE_ADMIN_PORT$index to ${MOBLABS[$moblab]}"
check_tunnel "$BASE_ADMIN_PORT$index" 9991 "${MOBLABS[$moblab]}"
+ echo
done
+ if [[ "${STATUS}" -eq 2 ]]; then
+ # Pick only the first host in case user enter more then one.
+ set -- $mobs
+ m=$1
+ echo Connecting to $m with IP ${MOBLABS[$m]}
+ ssh root@${MOBLABS[$m]}
+ fi
else
usage
fi
@@ -107,12 +117,14 @@
-c Close active or specified tunnels.
-h Print this.
-o Open all tunnels or only those specified.
- -s Checks the status of each active tunnel."
+ -s Checks the status of each active tunnel.
+ -u Connect to moblab via ssh.
+ "
}
OPTIND=1
-while getopts "achos" opt; do
+while getopts "achosu" opt; do
case "$opt" in
a)
MONITOR_PORT=1
@@ -130,6 +142,9 @@
s)
STATUS=1
;;
+ u)
+ STATUS=2
+ ;;
esac
done
@@ -138,7 +153,3 @@
[[ "$1" = "--" ]] && shift
start "$@"
-
-
-
-