Magellan Linux

Contents of /trunk/usbip/usbippolld-sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 185 - (show annotations) (download)
Tue May 15 14:39:55 2007 UTC (17 years ago) by niro
File size: 830 byte(s)
-using ip as primary key

1 #!/bin/bash
2
3 source /etc/conf.d/usbippolld
4 source /usr/lib/alxconfig-ng/functions/mysqlfunctions
5
6 while true
7 do
8 ALLCLIENTS=$(mysqldo "select ip from clients")
9
10 for client in ${ALLCLIENTS}
11 do
12 # filter all not connected clients
13 if [[ $(mysqldo "select connected from clients where ip='${client}'") = 1 ]]
14 then
15 BUSID=$(mysqldo "select busid from clients where ip='${client}'")
16
17 echo "-- polling client #${client} on dev ${BUSID}"
18 usbip -a ${client} ${BUSID}
19 else
20 echo "-- client #${client} not found, removing from list"
21
22 out=$(mktemp)
23 port=$(usbip -p &> ${out};grep -B3 -i "${client}" ${out} | grep Port | cut -d' ' -f2| sed "s|:||")
24 [[ ! -z ${port} ]] && usbip -d ${port}
25
26 mysqldo "update clients set connected='0', busid='' where ip='${client}'"
27 fi
28
29 done
30
31 sleep ${USBIP_WAIT_TIMEOUT}
32 done

Properties

Name Value
svn:executable *