#!/bin/bash # Script to connect to a USB device via USB/IP. # Don't forget to do chmod +x and fill in "HOST" variable # # Put this into /usr/bin/usbip-setup on host ############### # Settings HOST="X.X.X.X" VENDORID="1d50" DEVICEID="614e" ############### USBID="$VENDORID:$DEVICEID" while ! `nc -z "$HOST" 3240`; do echo "Waiting for USB/IP..." sleep 1 done bus_id() { usbip list -r "$HOST" -p | grep "$USBID" | cut -d ':' -f 1 | xargs } is_connected() { lsusb -d "$USBID" >/dev/null && return 0 BUSID=`bus_id` [ -z "$BUSID" ] && return 1 usbip attach -r "$HOST" -b "$BUSID" && return 0 return 1 } while ! `is_connected`; do echo "Retrying..." sleep 1 done echo "USB device has been connected"