Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: tools/android/adb_remote_setup.sh

Issue 120263003: Add a script for configuring adb for working remotely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added auto-update capability Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/adb_remote_setup.sh
diff --git a/tools/android/adb_remote_setup.sh b/tools/android/adb_remote_setup.sh
new file mode 100755
index 0000000000000000000000000000000000000000..7df6ed41178e12bcc4f9850175ac273cc518b63a
--- /dev/null
+++ b/tools/android/adb_remote_setup.sh
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# 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 -f -o "$new_script" "$script_url" || return
aelias_OOO_until_Jul13 2014/02/07 02:17:24 Macs don't ship with curl, so we should have an er
newt (away) 2014/02/07 02:49:48 Ok, I can add that. Though this stackoverflow answ
aelias_OOO_until_Jul13 2014/02/07 03:00:42 OK, never mind then, I must've confused it with wg
+ 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 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
+EOF
+ exit 1
+fi
+
+remote_host="$1"
+remote_adb="$2"
aelias_OOO_until_Jul13 2014/02/07 02:17:24 Could you make this default to just "adb"? I thin
newt (away) 2014/02/07 02:49:48 I tried this, but it doesn't work for me, since .b
aelias_OOO_until_Jul13 2014/02/07 03:00:42 Yes, it does work. That's probably because I have
+
+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"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698