Magellan Linux

Annotation of /trunk/usbip/usbipdevd-sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 174 - (hide annotations) (download)
Wed May 9 15:05:23 2007 UTC (17 years ago) by niro
File size: 1157 byte(s)
-sql version

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