Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 3 # URL from which the latest version of this script can be downloaded. | |
| 4 script_url="http://src.chromium.org/svn/trunk/src/tools/android/adb_remote_setup .sh" | |
| 5 | |
| 6 # Replaces this file with the latest version of the script and runs it. | |
| 7 update-self() { | |
| 8 local script="${BASH_SOURCE[0]}" | |
| 9 local new_script="${script}.new" | |
| 10 local updater_script="${script}.updater" | |
| 11 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
| |
| 12 chmod +x "$new_script" || return | |
| 13 | |
| 14 # Replace this file with the newly downloaded script. | |
| 15 cat > "$updater_script" << EOF | |
| 16 #!/bin/bash | |
| 17 if mv "$new_script" "$script"; then | |
| 18 rm -- "$updater_script" | |
| 19 else | |
| 20 echo "Note: script update failed." | |
| 21 fi | |
| 22 ADB_REMOTE_SETUP_NO_UPDATE=1 exec /bin/bash "$script" $@ | |
| 23 EOF | |
| 24 exec /bin/bash "$updater_script" "$@" | |
| 25 } | |
| 26 | |
| 27 if [[ "$ADB_REMOTE_SETUP_NO_UPDATE" -ne 1 ]]; then | |
| 28 update-self "$@" || echo 'Note: script update failed' | |
| 29 fi | |
| 30 | |
| 31 if [[ $# -ne 2 ]]; then | |
| 32 cat <<'EOF' | |
| 33 Usage: adb_remote_setup.sh REMOTE_HOST REMOTE_ADB | |
| 34 | |
| 35 Configures adb on a remote machine to communicate with a device attached to the | |
| 36 local machine. This is useful for installing APKs, running tests, etc while | |
| 37 working remotely. | |
| 38 | |
| 39 Arguments: | |
| 40 REMOTE_HOST hostname of remote machine | |
| 41 REMOTE_ADB path to adb on the remote machine | |
| 42 EOF | |
| 43 exit 1 | |
| 44 fi | |
| 45 | |
| 46 remote_host="$1" | |
| 47 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
| |
| 48 | |
| 49 if which kinit >/dev/null; then | |
| 50 # Allow ssh to succeed without typing your password multiple times. | |
| 51 kinit -R || kinit | |
| 52 fi | |
| 53 | |
| 54 # Kill the adb server on the remote host. | |
| 55 ssh "$remote_host" "$remote_adb kill-server" | |
| 56 | |
| 57 # Start the adb server locally. | |
| 58 adb start-server | |
| 59 | |
| 60 # Forward various ports from the remote host to the local host: | |
| 61 # 5037: adb | |
| 62 # 8001: http server | |
| 63 # 9031: sync server | |
| 64 # 10000: net unittests | |
| 65 # 10201: net unittests | |
| 66 ssh -C \ | |
| 67 -R 5037:localhost:5037 \ | |
| 68 -L 8001:localhost:8001 \ | |
| 69 -L 9031:localhost:9031 \ | |
| 70 -R 10000:localhost:10000 \ | |
| 71 -R 10201:localhost:10201 \ | |
| 72 "$remote_host" | |
| OLD | NEW |