Advertisement
Guest User

usbip

a guest
Oct 14th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.92 KB | None | 0 0
  1. Unit]
  2. Description=USB-IP Client Auto Binding on BusID
  3. After=network-online.target usbipd.service
  4. Wants=network-online.target
  5. Requires=usbipd.service
  6. [Service]
  7. Type=simple
  8. ExecStart=/usr/bin/usbip-bindr.sh
  9. RemainAfterExit=yes
  10. ExecStop=/usr/bin/usbip-unbindr.sh
  11. Restart=on-failure
  12. [Install]
  13. WantedBy=multi-user.target
  14.  
  15. #!/bin/bash
  16. # This attaches the USB device.
  17. # /usr/lib/systemd/system/usbip-bindr.service
  18.  
  19. usbiplistdevice="$(/usr/bin/usbip list -r 127.0.0.1 | grep 138a:003f | awk -F ":" '{print $1}' | sed s/' '//g | grep -v "^$")"
  20. /usr/bin/usbip attach -r 127.0.0.1 -b "$usbiplistdevice"
  21.  
  22. /usr/bin/usbip-bindr.sh
  23. #!/bin/bash
  24. # This detaches the USB device.
  25. # /usr/lib/systemd/system/usbip-bindr.service
  26.  
  27. /usr/bin/usbip-unbindr.sh
  28. #!/usr/bin/bash
  29. usbipunbind="$(/usr/bin/usbip port | grep "Port in Use" | awk -F ":" '{print $1}' | sed s/'Port '//g | grep -v "^$")"
  30. /usr/bin/usbip detach -p "$usbipunbind"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement