| 8 | | # try to get the device path from udevinfo. |
| 9 | | if [ -z "$DEVICE" -a -u "$DEVNAME" ] |
| 10 | | then |
| 11 | | if [ -z "$DEVPATH" ] |
| 12 | | then |
| | 12 | # if udev supplied a device node directly from the usb-device, we use it, |
| | 13 | # because it is guaranteed to exist at the time we run |
| | 14 | if [ -n "$DEVNAME" -a -e "$DEVNAME" ]; then |
| | 15 | DEVICE="$DEVNAME" |
| | 16 | fi |
| | 17 | |
| | 18 | [ -n "$DEVICE" ] || exit 0 |
| | 19 | |
| | 20 | if [ -z "$PRODUCT" -a -n "$MODALIAS" ]; then |
| | 21 | PRODUCT=$(echo $MODALIAS | sed -e 's/usb:v\(....\)p\(....\)d\(....\).*/\1\/\2\/\3/g' |tr A-F a-f) |
| | 22 | fi |
| | 23 | |
| | 24 | if [ -z "$PRODUCT" ]; then |
| | 25 | V=$(cat /sys$(dirname $DEVPATH)/idVendor | sed -e 's/^0*//') |
| | 26 | P=$(cat /sys$(dirname $DEVPATH)/idProduct | sed -e 's/^0*//') |
| | 27 | D=$(cat /sys$(dirname $DEVPATH)/bcdDevice | sed -e 's/^0*//') |
| | 28 | PRODUCT="$V/$P/$D" |
| | 29 | fi |
| | 30 | |
| | 31 | [ -n "$PRODUCT" ] || exit 0 |
| | 32 | |
| | 33 | # we may neeed to wait for the device node, when usbfs is used |
| | 34 | for A in "0 1 2 3 4 5 6 7 8 9"; do |
| | 35 | if [ -e "$DEVICE" ]; then |
| | 36 | SBINDIR/openct-control attach usb:$PRODUCT usb $DEVICE |
| 23 | | if [ -n "$DEVICE" ] |
| 24 | | then |
| 25 | | for A in `seq 10` |
| 26 | | do |
| 27 | | if test -e $DEVICE |
| 28 | | then |
| 29 | | if test -z "$PRODUCT" |
| 30 | | then |
| 31 | | PRODUCT="`echo $MODALIAS |sed -e "s/usb:v\(....\)p\(....\)d\(....\).*/\1\/\2\/\3/g" |tr A-F a-f`" |
| 32 | | fi |
| 33 | | |
| 34 | | # if you see two ifdhandlers for one device, then you can |
| 35 | | # either comment out the next line here ... |
| 36 | | SBINDIR/openct-control attach usb:$PRODUCT usb $DEVICE |
| 37 | | exit 0 |
| 38 | | fi |
| 39 | | sleep 0.1 |
| 40 | | done |
| 41 | | echo "$0 waited for $DEVICE but it did not appear." \ |
| 42 | | |logger -p daemon.error |
| 43 | | exit 1 |
| 44 | | fi |
| 45 | | |
| 46 | | if [ -n "$DEVNAME" ] |
| 47 | | then |
| 48 | | for A in `seq 10` |
| 49 | | do |
| 50 | | if test -e $DEVNAME |
| 51 | | then |
| 52 | | V="`cat /sys/$DEVPATH/device/idVendor |sed -e "s/^0*//"`" |
| 53 | | P="`cat /sys/$DEVPATH/device/idProduct|sed -e "s/^0*//"`" |
| 54 | | D="`cat /sys/$DEVPATH/device/bcdDevice |sed -e "s/^0*//"`" |
| 55 | | PRODUCT="$V/$P/$D" |
| 56 | | # or the following line. both should disable that effect. |
| 57 | | SBINDIR/openct-control attach usb:$PRODUCT usb $DEVNAME |
| 58 | | |
| 59 | | exit 0 |
| 60 | | fi |
| 61 | | sleep 0.1 |
| 62 | | done |
| 63 | | echo "$0 waited for $DEVNAME but it did not appear." \ |
| 64 | | |logger -p daemon.error |
| 65 | | exit 1 |
| 66 | | fi |
| 67 | | |
| 68 | | ) & |
| 69 | | disown %1 |
| 70 | | |
| | 42 | echo "$0 waited for $DEVICE but it did not appear." | logger -p daemon.error |