Sophie

Sophie

distrib > Mandriva > 2008.0 > x86_64 > media > main-backports-src > by-pkgid > 7728fbb2facddeae66aab697f9e7b30c > files > 10

sane-1.0.19-3mdv2008.0.src.rpm

#!/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