Skip to content

Instantly share code, notes, and snippets.

@kamawanu
Created September 24, 2016 04:56
Show Gist options
  • Save kamawanu/0f81c6e7cc827963b9a620b6cd31adb7 to your computer and use it in GitHub Desktop.
Save kamawanu/0f81c6e7cc827963b9a620b6cd31adb7 to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
DEV=${1-$ANDROID_SERIAL}
set +x
# http://blog.be-dama.com/2012/10/01/%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%A7usb%E3%83%87%E3%83%90%E3%82%A4%E3%82%B9%E3%82%92%E6%93%8D%E4%BD%9C/
for P in $( find /sys/bus/usb/devices/ )
do
if [ -f $P/serial ]
then
IT_SERIAL=$( cat $P/serial )
echo $IT_SERIAL $( cat $P/{product,manufacturer} )
if [ x$IT_SERIAL == x$DEV ]
then
USBPOS=$( echo $P | cut -d/ -f6 )
echo -n $USBPOS | dd of=/sys/bus/usb/drivers/usb/unbind || sudo chmod og+w /sys/bus/usb/drivers/usb/*bind
sleep 1
echo -n $USBPOS | dd of=/sys/bus/usb/drivers/usb/bind
sleep 1
##exit 9
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment