Magellan Linux

Annotation of /trunk/usbip/usbipdevd-sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 178 - (hide annotations) (download)
Thu May 10 14:12:40 2007 UTC (17 years ago) by niro
File size: 1156 byte(s)
-using SESSIONID instead of CLIENTIP to identify clients

1 niro 174 #!/bin/bash
2    
3     source /etc/conf.d/usbipdevd
4     source /usr/lib/alxconfig-ng/functions/mysqlfunctions
5    
6     CLIENTIP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
7    
8 niro 178 # get a free session id
9     SESSIONID=$(mysqldo "insert into clients (ip,connected) values('${CLIENTIP}','1');select last_insert_id();")
10 niro 174
11     while true
12     do
13     BUSID=$(bind_driver --list | grep -i ${USBIP_DEVICE_ID} | cut -d ' ' -f4)
14    
15     if [[ -n ${BUSID} ]]
16     then
17     echo "BUSID: ${BUSID}"
18    
19     # abort if nothing has changed
20 niro 178 if [[ $(mysqldo "select connected from clients where id='${SESSIONID}'") = 1 ]] &&
21     [[ $(mysqldo "select busid from clients where id='${SESSIONID}'") = ${BUSID} ]]
22 niro 174 then
23     echo "USBID is the same; nothing changed"
24     else
25     echo "exporting Logitech Pen with ID ${BUSID}"
26     bind_driver --usbip ${BUSID}
27 niro 178 mysqldo "update clients set ip='${CLIENTIP}', connected='1', busid='${BUSID}' where id='${SESSIONID}'"
28 niro 174 fi
29     else
30     echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..."
31 niro 178 mysqldo "update clients set ip='${CLIENTIP}', connected='0', busid='${BUSID}' where id='${SESSIONID}'"
32 niro 174 fi
33    
34     sleep ${USBIP_WAIT_TIMEOUT}
35     done
36    
37 niro 178 mysqldo "delete from clients where id='${SESSIONID}')"