#!/bin/bash source /etc/conf.d/usbippolld while true do ALLCLIENTS=$(find ${USBIP_TEMP} -type f | sort) for i in ${ALLCLIENTS} do client=$(basename ${i} .txt) dev=$(< ${i}) if fping -q ${FPING_OPTS} ${client} then echo "-- polling client ${client} on dev ${dev}" usbip -a ${client} ${dev} else echo "-- client ${client} not found, removing from list" out=$(mktemp) port=$(portusbip -p &> ${out};grep -B3 -i "128.20.3.3" ${out} | grep Port | cut -d' ' -f2| sed "s|:||") usbip -d ${port} rm ${out} rm ${tmp}/${client} fi sleep ${USBIP_WAIT_TIMEOUT} done done