1
0
mirror of https://github.com/google/adb-sync.git synced 2026-01-03 09:58:01 +00:00
Files
adb-sync/adb-channel
Rudolf Polzer 9b9a7041ff adb-channel: In fact, safely exit also on SIGINT, SIGTERM and SIGALRM,
as all these usually intend a "clean" exit.
2015-05-03 15:52:58 +02:00

23 lines
467 B
Bash
Executable File

#!/bin/sh
set -e
t=`mktemp -d -t adb-channel.XXXXXX`
remote=${1}
activity=${2}
delay=${3}
atexit() {
[ -z "${activity}" ] || adb shell am force-stop ${activity%%/*}
adb forward --remove localfilesystem:"${t}/sock"
rm -rf "${t}"
}
trap atexit EXIT
trap 'exit 0' HUP INT ALRM TERM
[ -z "${activity}" ] || adb shell am start -W ${activity}
[ -z "${delay}" ] || sleep "${delay}"
adb forward localfilesystem:"${t}/sock" "${remote}"
socat stdio unix:"${t}/sock"