These scripts help to automate usbip on the server and client side.
Please note that this project is WIP, the server side should be functional and complete, the client side is functional but incomplete.
A copy of these notes has been added to: https://openwrt.org/docs/guide-user/services/usb.iptunnel
A server, in my case it is an old Router with openwrt and a firmware that includes usbip. A client, in my case a pop! Linux (ubuntu based distribution).
Within openwrt, during boot the file '/etc/rc.local' will be checked for custom commands. And run the hotplug script '/etc/hotplug.d/usb/90-usbip' on boot.
Otherwise during normal operation the hotplug script will run everytime when a device is beeing plugged in or beeing removed.
Use scp to copy the files to openwrt.
scp 90-usbip root@openwrt.lan:/etc/hotplug.d/usb/90-usbip
scp usbip_share_these_devices.list root@openwrt.lan:/etc/usbip_share_these_devices.listConnect to the server using ssh
ssh root@openwrt.lanSetup the scripts
# Download and install usbip
opkg update && opkg install usbip-server usbip-client
# Make the script executable by adding
# these lines to: rc.local before the exit 0
[ -x /etc/hotplug.d/usb/90-usbip ] || chmod 750 /etc/hotplug.d/usb/90-usbip
/etc/hotplug.d/usb/90-usbip 1
# Run these commands, in order to keep your custom configurations when running sysupgrades of openwrt.
echo "/etc/hotplug.d/usb/90-usbip" >> /etc/sysupgrade.conf
echo "/etc/usbip_share_these_devices.list" >> /etc/sysupgrade.conf
echo "/etc/rc.local" >> /etc/sysupgrade.confThe script '/usr/local/bin/remote_connect_usbip.sh' gets executed once a minute using cron. I checks if the server side does share devices over usbip and attaches all of them.
Setup the script
# Copy it somwehere that makes sense.
sudo cp remote_connect_usbip.sh /usr/local/bin/remote_connect_usbip.sh
# Make Script executable
sudo chmod +x /usr/local/bin/remote_connect_usbip.sh
# Run the script once not using cron to check the dependencies.
sudo /usr/local/bin/remote_connect_usbip.shEdit crontab
sudo crontab -eAdd this to crontab (script will execute once per minute)
# connect usb devices using usbip from remote server.
* * * * * /usr/local/bin/your_script.sh
Wait a minute
# check if script gets executed
grep CRON /var/log/syslog