sorccu / docker-adb

Dockerfile and instructions for ADB.
Other
200 stars 74 forks source link

How to auto connect devices on container restart #17

Open mkono87 opened 5 years ago

mkono87 commented 5 years ago

I set this up on my unraid machine. All my containers shutdown for backups over night so I need a way to have it auto connect again to my devices. Possible?

ajobbins commented 5 years ago

Interested in this too. I am connecting via network, not USB. I have to run 'adb connect 192.168.x.x' after container is started, or it's not connected to my device. I'm hoping this can happen automatically on container start

mkono87 commented 5 years ago

@ajobbins See with this script it connects on startup

#!/bin/sh

sleep 5

DEVICES="192.168.0.206"

echo "Connecting to devices."
for device in $DEVICES; do
   adb connect $device
done
echo "Done."

while true; do
  for device in $DEVICES; do
    adb connect $device > /dev/null 2>&1
  done
  sleep 60
done

When I start he container is auto connects

Connecting to devices.
* daemon not running; starting now at tcp:5037
* daemon started successfully
connected to 192.168.0.206:5555
Done.

But HA is unable to connect to it. So I cant catch a break.

Mon Apr 01 2019 11:29:16 GMT-0400 (Eastern Daylight Time)
Could not connect to mike firetv at 192.168.0.206:5555 using ADB server at 192.168.0.50:5037