Magellan Linux

Annotation of /trunk/usbip/usbippolld-sql

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *