--- trunk/usbip/usbipdevd-sql 2007/05/09 15:05:23 174 +++ trunk/usbip/usbipdevd-sql 2007/05/10 14:12:40 178 @@ -1,17 +1,12 @@ #!/bin/bash source /etc/conf.d/usbipdevd - -SQL_USER=jomo -SQL_PASS=j0m0 -SQL_HOST=128.20.41.110 -SQL_DB=jomo - source /usr/lib/alxconfig-ng/functions/mysqlfunctions CLIENTIP=$(/sbin/ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp') -mysqldo "insert into clients (ip,connected) values('128.20.39.217','1')" +# get a free session id +SESSIONID=$(mysqldo "insert into clients (ip,connected) values('${CLIENTIP}','1');select last_insert_id();") while true do @@ -22,22 +17,21 @@ echo "BUSID: ${BUSID}" # abort if nothing has changed - if [[ $(mysqldo "select connected from clients where ip='${CLIENTIP}'") = 1 ]] && - [[ $(mysqldo "select busid from clients where ip='${CLIENTIP}'") = ${BUSID} ]] + if [[ $(mysqldo "select connected from clients where id='${SESSIONID}'") = 1 ]] && + [[ $(mysqldo "select busid from clients where id='${SESSIONID}'") = ${BUSID} ]] then echo "USBID is the same; nothing changed" else echo "exporting Logitech Pen with ID ${BUSID}" bind_driver --usbip ${BUSID} - 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}'" fi else echo "No Logitech Pen (${USBIP_DEVICE_ID}) found ..." - 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}'" fi sleep ${USBIP_WAIT_TIMEOUT} done -mysqldo "delete from clients where ip='${CLIENTIP}')" - +mysqldo "delete from clients where id='${SESSIONID}')"