Magellan Linux

Contents of /trunk/usbip/usbipdevd-sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 186 - (show annotations) (download)
Tue May 15 14:52:40 2007 UTC (16 years, 11 months ago) by niro
File size: 1116 byte(s)
fixed a typo

1 #!/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 # 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
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 if [[ $(mysqldo "select connected from clients where ip='${CLIENTIP}'") = 1 ]] &&
24 [[ $(mysqldo "select busid from clients where ip='${CLIENTIP}'") = ${BUSID} ]]
25 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 mysqldo "update clients set connected='1', busid='${BUSID}' where ip='${CLIENTIP}'"
31 fi
32 else
33 echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..."
34 mysqldo "update clients set connected='0', busid='${BUSID}' where ip='${CLIENTIP}'"
35 fi
36
37 sleep ${USBIP_WAIT_TIMEOUT}
38 done