Last active
February 9, 2022 00:22
-
-
Save kamawanu/686936614e8879cf4db19d6daf49f38a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
for P in $( find /sys/bus/usb/devices/ ) | |
do | |
if [ \! -f $P/serial ] | |
then | |
continue | |
fi | |
# if [ $( cat $P/bDeviceClass ) == 09 ] | |
# then | |
# continue | |
# fi | |
IT_SERIAL=$( cat $P/serial ) | |
#? case $IT_SERIAL in | |
#? 0000:00:*) | |
#? continue; | |
#? esac | |
echo $IT_SERIAL $( cat $P/id* ) $P $( | |
cat $P/{product,manufacturer,bDevice*,removable} ) | |
#,subsystem/drivers_* | |
USBPOS=$( echo $P | cut -d/ -f6 ) | |
find $P/. -name interface | xargs cat | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
KEYW=${1-xxxxxxx} | |
install_adb () { | |
echo $2:$3 | |
echo "SUBSYSTEM==\"usb\", ATTR{idVendor}==\"$2\", ATTR{idProduct}==\"$3\", MODE=\"666\", GROUP=\"plugdev\"" | sudo tee /etc/udev/rules.d/51-android-$2-$3.rules | |
# sudo udevadm control --reload | |
# adb devices | |
# sudo adb kill-server | |
# sudo adb devices | |
} | |
for P in $( find /sys/bus/usb/devices/ ) | |
do | |
if [ \! -f $P/serial ] | |
then | |
continue | |
fi | |
# if [ $( cat $P/bDeviceClass ) == 09 ] | |
# then | |
# continue | |
# fi | |
IT_SERIAL=$( cat $P/serial ) | |
case $IT_SERIAL in | |
0000:00:*) | |
continue; | |
esac | |
adb devices | fgrep $IT_SERIAL && continue | |
LINE=$( echo $IT_SERIAL $( cat $P/{idVendor,idProduct} ) $P $( cat $P/{product,manufacturer,bDevice*,removable} ) ) | |
echo $LINE | |
#,subsystem/drivers_* | |
###USBPOS=$( echo $P | cut -d/ -f6 ) | |
##find $P/. -name interface | xargs cat | |
FOUND=$( echo $LINE | fgrep $KEYW ) || true | |
if [ "x$FOUND" != x ] | |
then | |
install_adb $FOUND | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://android.stackexchange.com/a/101065 | |
wget -N https://skia.googlesource.com/skia/+archive/cd048d18e0b81338c1a04b9749a00444597df394/platform_tools/android/bin/linux.tar.gz | |
tar xvfz linux.tar.gz | |
sudo install adb -o 0 $( which adb ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://askubuntu.com/a/644222 | |
sudo udevadm control --reload-rules | |
sudo service udev restart | |
sudo udevadm trigger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 disabled | dd of=$P/power/level #|| sudo chmod og+w /sys/bus/usb/drivers/usb/*bind | |
echo -n on | dd of=$P/power/level || sudo chmod og+w $P/power/level | |
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