#!/bin/bash source /etc/conf.d/usbippolld source /usr/lib/alxconfig-ng/functions/mysqlfunctions while true do ALLCLIENTS=$(mysqldo "select ip from clients") for client in ${ALLCLIENTS} do # filter all not connected clients if [[ $(mysqldo "select connected from clients where ip='${client}'") = 1 ]] then BUSID=$(mysqldo "select busid from clients where ip='${client}'") echo "-- polling client #${client} on dev ${BUSID}" usbip -a ${client} ${BUSID} else echo "-- client #${client} not found, removing from list" out=$(mktemp) port=$(usbip -p &> ${out};grep -B3 -i "${client}" ${out} | grep Port | cut -d' ' -f2| sed "s|:||") [[ ! -z ${port} ]] && usbip -d ${port} mysqldo "update clients set connected='0', busid='' where ip='${client}'" fi done sleep ${USBIP_WAIT_TIMEOUT} done