Magellan Linux

Diff of /trunk/usbip/usbipdevd-sql

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

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

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