Magellan Linux

Contents of /trunk/usbip/usbipdevd2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1538 - (show annotations) (download)
Mon Sep 19 18:53:59 2011 UTC (12 years, 7 months ago) by niro
File size: 1354 byte(s)
-check for list2 and fixed a typo
1 #!/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 # version 0.1.7, no parseable list cmd
11 if [[ -x /usr/bin/bind_driver ]]
12 then
13 BINDCMD="/usr/bin/bind_driver"
14 else
15 BINDCMD="/usr/sbin/usbip_bind_driver"
16 fi
17
18 while true
19 do
20 # version =<0.1.7 has no parseable list cmd
21 if [[ -z $(${BINDCMD} --help | grep -- --list2) ]]
22 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 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 fi
29
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 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 else
42 echo "USB Device '${USBIP_DEVICE_ID}' not found ..."
43 fi
44
45 sleep ${USBIP_POLLING_TIME}
46 done