#!/bin/bash # This file was installed by the sane-backends package. # # This script changes the permissions and ownership of a USB device under # /proc/bus/usb to grant access to this device to users in the usb group # and the first user that logged in. # # Ownership is set to $USER.usb, where $USER is the first user that logged # in (through pam_console). If there is no user logged in, the ownership # will get set to root.usb. Permissions are set to 0660. # # Arguments : # ----------- # ACTION=[add|remove] # DEVICE=/proc/bus/usb/BBB/DDD # TYPE=usb SCRIPT=/etc/dynamic/scripts/scanner.script if [ "$TYPE" = "usb" -a -f "${DEVICE}" ]; then if [ "$ACTION" = "add" ]; then if [ -f /var/run/console.lock ]; then USER=`cat /var/run/console.lock` else USER=root fi # sanity check if [ -z $USER ]; then USER=root fi chown $USER:usb "$DEVICE" chmod 0660 "$DEVICE" if [ -x $SCRIPT ]; then # don't call it twice [ -x "$REMOVER" ] && exit 0 # call dynamic stuff $SCRIPT add "$DEVICE" if [ -n "$REMOVER" ]; then cat > $REMOVER <<EOF #!/bin/sh $SCRIPT del "${DEVICE}" EOF chmod +x $REMOVER fi fi fi fi