Annotation of /trunk/usbip/usbipdevd-sql
Parent Directory | Revision Log
Revision 185 -
(hide annotations)
(download)
Tue May 15 14:39:55 2007 UTC (17 years, 5 months ago) by niro
File size: 1115 byte(s)
Tue May 15 14:39:55 2007 UTC (17 years, 5 months ago) by niro
File size: 1115 byte(s)
-using ip as primary key
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 | 185 | # create a new ip entry if none exist |
9 | if [[ -z $(mysqldo "select ip from clients where ip='${CLIENTIP}") ]] | ||
10 | then | ||
11 | mysqldo "insert into clients (ip,connected) values('${CLIENTIP}','0')" | ||
12 | fi | ||
13 | niro | 174 | |
14 | while true | ||
15 | do | ||
16 | BUSID=$(bind_driver --list | grep -i ${USBIP_DEVICE_ID} | cut -d ' ' -f4) | ||
17 | |||
18 | if [[ -n ${BUSID} ]] | ||
19 | then | ||
20 | echo "BUSID: ${BUSID}" | ||
21 | |||
22 | # abort if nothing has changed | ||
23 | niro | 185 | if [[ $(mysqldo "select connected from clients where ip='${CLIENTIP}'") = 1 ]] && |
24 | [[ $(mysqldo "select busid from clients where ip='${CLIENTIP}'") = ${BUSID} ]] | ||
25 | niro | 174 | then |
26 | echo "USBID is the same; nothing changed" | ||
27 | else | ||
28 | echo "exporting Logitech Pen with ID ${BUSID}" | ||
29 | bind_driver --usbip ${BUSID} | ||
30 | niro | 185 | mysqldo "update clients set connected='1', busid='${BUSID}' where ip='${CLIENTIP}'" |
31 | niro | 174 | fi |
32 | else | ||
33 | echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..." | ||
34 | niro | 185 | mysqldo "update clients set connected='0', busid='${BUSID}' where ip='${CLIENTIP}'" |
35 | niro | 174 | fi |
36 | |||
37 | sleep ${USBIP_WAIT_TIMEOUT} | ||
38 | done |