#!/usr/bin/env bash # Root-only monitor for an existing loopback ads-usb export. No public USB/IP listener. set -euo pipefail port=${1:-3241} [[ "$port" =~ ^[0-9]{1,5}$ ]] && ((port>=1024 && port<=65535)) || { echo 'Invalid USB/IP port' >&2; exit 2; } ((EUID==0)) || { echo 'usbip attach requires root' >&2; exit 1; } modprobe vhci_hcd uri="usbip://127.0.0.1:$port/1-1" while true; do if ! usbip port | grep -F -- "$uri" >/dev/null; then usbip --tcp-port "$port" attach --remote 127.0.0.1 --busid 1-1 || true fi sleep 3 done