#!/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 or PHYSDEVBUS=usb SCRIPT=/etc/dynamic/scripts/scanner.script if [ "$TYPE" = "usb" -o "$PHYSDEVBUS" = "usb" ] && [ -f "${DEVICE}" ]; then if [ "$ACTION" = "add" ]; then USER= if [ -f /var/run/console.lock ]; then USER=`cat /var/run/console.lock` fi [ -z $USER ] && USER=root chown $USER:usb "$DEVICE" chmod 0660 "$DEVICE" fi if [ "$ACTION" = "add" -o "$ACTION" = "remove" ] && [ -x $SCRIPT ]; then DEVNAME=$DEVICE export DEVNAME sh -x $SCRIPT & fi fi