#!/bin/bash if [ "$HAL_PROP_USB_BUS_NUMBER" ] && [ "$HAL_PROP_USB_LINUX_DEVICE_NUMBER" ]; then bus_num=`printf %.3u $HAL_PROP_USB_BUS_NUMBER` dev_num=`printf %.3u $HAL_PROP_USB_LINUX_DEVICE_NUMBER` NUM_TRIES_LEFT=5 while [ $NUM_TRIES_LEFT -ge 0 ] && [ ! -c /dev/bus/usb/$bus_num/$dev_num ]; do sleep 1 NUM_TRIES_LEFT=$(($NUM_TRIES_LEFT - 1)) done [ -c /dev/bus/usb/$bus_num/$dev_num ] || exit 0 chown root:scanner /dev/bus/usb/$bus_num/$dev_num chmod a+rw /dev/bus/usb/$bus_num/$dev_num NUM_TRIES_LEFT=5 while [ $NUM_TRIES_LEFT -ge 0 ] && [ ! -f /proc/bus/usb/$bus_num/$dev_num ]; do sleep 1 NUM_TRIES_LEFT=$(($NUM_TRIES_LEFT - 1)) done [ -f /proc/bus/usb/$bus_num/$dev_num ] || exit 0 chown root:scanner /proc/bus/usb/$bus_num/$dev_num chmod a+rw /proc/bus/usb/$bus_num/$dev_num fi