diff options
author | newt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:46:13 +0000 |
---|---|---|
committer | newt@chromium.org <newt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 06:46:13 +0000 |
commit | facc34e2823c47ac9f54cf9ce418431bec611c12 (patch) | |
tree | f47d3cb79e698f1a73f5aa7fca0343a75422cd2a /tools/android | |
parent | e09aae566d29bc6efd8bb43285a519c2fc3ef70f (diff) | |
download | chromium_src-facc34e2823c47ac9f54cf9ce418431bec611c12.zip chromium_src-facc34e2823c47ac9f54cf9ce418431bec611c12.tar.gz chromium_src-facc34e2823c47ac9f54cf9ce418431bec611c12.tar.bz2 |
Revert "Revert 256769 "Add a script for configuring adb for working remo...""
> Revert 256769 "Add a script for configuring adb for working remo..."
>
> > Add a script for configuring adb for working remotely.
> >
> > This script forwards ports between the local and the remote
> > machine allowing the developer to install APKs, run tests, etc
> > on a local device from a remote machine.
> >
> > NOTRY=true
> >
> > Review URL: https://codereview.chromium.org/120263003
>
> TBR=newt@chromium.org
>
> Review URL: https://codereview.chromium.org/196793011
NOTRY=true
Review URL: https://codereview.chromium.org/198653003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android')
-rwxr-xr-x | tools/android/adb_remote_setup.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/android/adb_remote_setup.sh b/tools/android/adb_remote_setup.sh new file mode 100755 index 0000000..04b7d4f --- /dev/null +++ b/tools/android/adb_remote_setup.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# URL from which the latest version of this script can be downloaded. +script_url="http://src.chromium.org/svn/trunk/src/tools/android/adb_remote_setup.sh" + +# Replaces this file with the latest version of the script and runs it. +update-self() { + local script="${BASH_SOURCE[0]}" + local new_script="${script}.new" + local updater_script="${script}.updater" + curl -sSf -o "$new_script" "$script_url" || return + chmod +x "$new_script" || return + + # Replace this file with the newly downloaded script. + cat > "$updater_script" << EOF +#!/bin/bash +if mv "$new_script" "$script"; then + rm -- "$updater_script" +else + echo "Note: script update failed." +fi +ADB_REMOTE_SETUP_NO_UPDATE=1 exec /bin/bash "$script" $@ +EOF + exec /bin/bash "$updater_script" "$@" +} + +if [[ "$ADB_REMOTE_SETUP_NO_UPDATE" -ne 1 ]]; then + update-self "$@" || echo 'Note: script update failed' +fi + +if [[ $# -ne 1 && $# -ne 2 ]]; then + cat <<'EOF' +Usage: adb_remote_setup.sh REMOTE_HOST [REMOTE_ADB] + +Configures adb on a remote machine to communicate with a device attached to the +local machine. This is useful for installing APKs, running tests, etc while +working remotely. + +Arguments: + REMOTE_HOST hostname of remote machine + REMOTE_ADB path to adb on the remote machine (you can omit this if adb is in + the remote host's path) +EOF + exit 1 +fi + +remote_host="$1" +remote_adb="${2:-adb}" + +if which kinit >/dev/null; then + # Allow ssh to succeed without typing your password multiple times. + kinit -R || kinit +fi + +# Kill the adb server on the remote host. +ssh "$remote_host" "$remote_adb kill-server" + +# Start the adb server locally. +adb start-server + +# Forward various ports from the remote host to the local host: +# 5037: adb +# 8001: http server +# 9031: sync server +# 10000: net unittests +# 10201: net unittests +ssh -C \ + -R 5037:localhost:5037 \ + -L 8001:localhost:8001 \ + -L 9031:localhost:9031 \ + -R 10000:localhost:10000 \ + -R 10201:localhost:10201 \ + "$remote_host" |