Magellan Linux

Diff of /trunk/usbip/usbipdevd-sql

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 178 by niro, Thu May 10 14:12:40 2007 UTC revision 185 by niro, Tue May 15 14:39:55 2007 UTC
# Line 5  source /usr/lib/alxconfig-ng/functions/m Line 5  source /usr/lib/alxconfig-ng/functions/m
5    
6  CLIENTIP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')  CLIENTIP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp')
7    
8  # get a free session id  # create a new ip entry if none exist
9  SESSIONID=$(mysqldo "insert into clients (ip,connected) values('${CLIENTIP}','1');select last_insert_id();")  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  while true
15  do  do
# Line 17  do Line 20  do
20   echo "BUSID: ${BUSID}"   echo "BUSID: ${BUSID}"
21    
22   # abort if nothing has changed   # abort if nothing has changed
23   if [[ $(mysqldo "select connected from clients where id='${SESSIONID}'") = 1 ]] &&   if [[ $(mysqldo "select connected from clients where ip='${CLIENTIP}'") = 1 ]] &&
24   [[ $(mysqldo "select busid from clients where id='${SESSIONID}'") = ${BUSID} ]]   [[ $(mysqldo "select busid from clients where ip='${CLIENTIP}'") = ${BUSID} ]]
25   then   then
26   echo "USBID is the same; nothing changed"   echo "USBID is the same; nothing changed"
27   else   else
28   echo "exporting Logitech Pen with ID ${BUSID}"   echo "exporting Logitech Pen with ID ${BUSID}"
29   bind_driver --usbip ${BUSID}   bind_driver --usbip ${BUSID}
30   mysqldo "update clients set ip='${CLIENTIP}', connected='1', busid='${BUSID}' where id='${SESSIONID}'"   mysqldo "update clients set connected='1', busid='${BUSID}' where ip='${CLIENTIP}'"
31   fi   fi
32   else   else
33   echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..."   echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..."
34   mysqldo "update clients set ip='${CLIENTIP}', connected='0', busid='${BUSID}' where id='${SESSIONID}'"   mysqldo "update clients set connected='0', busid='${BUSID}' where ip='${CLIENTIP}'"
35   fi   fi
36    
37   sleep ${USBIP_WAIT_TIMEOUT}   sleep ${USBIP_WAIT_TIMEOUT}
38  done  done
   
 mysqldo "delete from clients where id='${SESSIONID}')"  

Legend:
Removed from v.178  
changed lines
  Added in v.185