Skip to content

Commit

Permalink
Make adb-channel able to start/stop a SSH server app automatically.
Browse files Browse the repository at this point in the history
  • Loading branch information
divVerent committed Apr 30, 2015
1 parent f7ca1e1 commit 9b43cee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ ADB Channel

This package also contains a separate tool called adb-channel, which is a
convenience wrapper to connect a networking socket on the Android device to
file descriptors on the PC side.
file descriptors on the PC side. It can even launch and shut down the given
application automatically!

It is best used as a `ProxyCommand` for SSH (intall
[SSHelper](https://play.google.com/store/apps/details?id=com.arachnoid.sshelper)
Expand All @@ -104,7 +105,7 @@ first) using a configuration like:
```
Host sshhelper
Port 2222
ProxyCommand adb-channel tcp:%d
ProxyCommand adb-channel tcp:%d com.arachnoid.sshelper/.SSHelperActivity 1
```

After adding this to `~/.ssh/config`, run `ssh-copy-id sshhelper`.
Expand Down
7 changes: 7 additions & 0 deletions adb-channel
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ set -e

t=`mktemp -d -t adb-channel.XXXXXX`

remote=${1}
activity=${2}
delat=${3}

atexit() {
[ -z "${activity}" ] || adb shell am force-stop ${activity%%/*}
adb forward --remove localfilesystem:"${t}/sock"
rm -rf "${t}"
}
trap atexit EXIT

[ -z "${activity}" ] || adb shell am start -W ${activity}
[ -z "${delay}" ] || sleep "${delay}"
adb forward localfilesystem:"${t}/sock" "${1}"
socat stdio unix:"${t}/sock"

0 comments on commit 9b43cee

Please sign in to comment.