Magellan Linux

Annotation of /trunk/usbip/usbipdevd2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1538 - (hide annotations) (download)
Mon Sep 19 18:53:59 2011 UTC (13 years, 1 month ago) by niro
File size: 1354 byte(s)
-check for list2 and fixed a typo
1 niro 1529 #!/bin/bash
2    
3     export LC_ALL=C
4    
5     source /etc/conf.d/usbipdevd
6    
7     # some sane defaults
8     [[ -z ${USBIP_POLLING_TIME} ]] && USBIP_POLLING_TIME="10"
9    
10 niro 1537 # version 0.1.7, no parseable list cmd
11     if [[ -x /usr/bin/bind_driver ]]
12     then
13 niro 1538 BINDCMD="/usr/bin/bind_driver"
14 niro 1537 else
15     BINDCMD="/usr/sbin/usbip_bind_driver"
16     fi
17    
18 niro 1529 while true
19     do
20 niro 1538 # version =<0.1.7 has no parseable list cmd
21     if [[ -z $(${BINDCMD} --help | grep -- --list2) ]]
22 niro 1537 then
23     BUSID=$(${BINDCMD} --list | grep -i "${USBIP_DEVICE_ID}" | sed 's:.*busid\ \([0-9].*\)\ (.*:\1:') # sanitizing syntax-highlighting )
24     BUSBINDING=$(${BINDCMD} --list | grep -A1 "${USBIP_DEVICE_ID}" | grep -- '->' | sed 's:.*->\ \(.*\):\1:')
25     else
26 niro 1538 BUSID=$(${BINDCMD} --list2 | grep "${USBIP_DEVICE_ID}" | cut -d'#' -f1 | sed 's:.*=\(.*\):\1:')
27     BUSBINDING=$(${BINDCMD} --list2 | grep "${USBIP_DEVICE_ID}" | cut -d'#' -f3 | sed 's:.*=\(.*\):\1:')
28 niro 1537 fi
29 niro 1529
30     if [[ -n ${BUSID} ]]
31     then
32     # abort here if the busid is the same, because the client connection is lost on new exports
33 niro 1537 case ${BUSBINDING} in
34     usbip) echo "USBID is the same; nothing changed" ;;
35     none)
36     echo "Exporting USB Device with ID ${BUSID}"
37     ${BINDCMD} --usbip ${BUSID}
38     ;;
39     *) echo "Warning: unkown BUSBINDING '${BUSBINDING}' of BUSID '${BUSID}'" ;;
40     esac
41 niro 1529 else
42     echo "USB Device '${USBIP_DEVICE_ID}' not found ..."
43     fi
44    
45 niro 1537 sleep ${USBIP_POLLING_TIME}
46 niro 1529 done