Skip to content

Commit

Permalink
powerCycleUsb
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharp38 committed Mar 29, 2024
1 parent 42075eb commit 97cb842
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/scripts/powerCycleUsb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Tcharp38
###

# Note: https://www.kernel.org/doc/Documentation/usb/power-management.txt

echo -n "powerCycleUsb.sh starting: "
date

Expand Down Expand Up @@ -45,9 +47,14 @@ echo "PORT='$PORT'"
if [ -e "/sys/bus/usb/drivers/usb/unbind" ]; then
echo "Disconnecting ${PORT}"
echo "$PORT" > /sys/bus/usb/drivers/usb/unbind
sleep 2
echo "Reconnecting ${PORT}"
echo "$PORT" > /sys/bus/usb/drivers/usb/bind
ERR=$?
if [ $ERR -ne 0 ]; then
sudo echo "= ERROR: 'unbind' failed ! Are you root ?"
else
sleep 2
echo "Reconnecting ${PORT}"
sudo echo "$PORT" > /sys/bus/usb/drivers/usb/bind
fi
else
echo "ERROR: No solution found to power cycle ${PORT}"
exit 4
Expand Down

0 comments on commit 97cb842

Please sign in to comment.